Project front End Knowledge Point Summary 1

Source: Internet
Author: User
Tags string to number

1. typeof the data type of the judging variable.
Use format:

typeof variable Name

2. String to Number:
parseint () string ———— > Integer.
Parsefloat () string ———— > Decimal.

3, judge whether it is not a number: IsNaN ()

4, the function of for-in statement:
1. Elements that can be used to iterate through an array. Note: Iterating through the array elements using the for-in statement is the subscript of the array.

2. Can be used to traverse all property data of an object. Note: When you use the For-in statement to traverse the properties of an object, the property names in the object are traversed.

var arr = [12,13,19,15,16];

For-in a statement to iterate over an array element
For (var index in arr) {
document.write (arr[index]+ ",");

Creating an object constructor
function person (ID, name) { = ID; = name;

Create an object (called the person () constructor function, which is equivalent to a constructor in Java)
var p = new Person (110, "Dog Doll");

For (Var property in P) {
document.write (p[property]+ ",");

5. Creating JavaScript Objects

Person=new Object ();
Person.firstname= "Bill";
Person.lastname= "Gates";
Person.eyecolor= "Blue";

Alternative syntax:
Person={firstname: "John", LastName: "Doe", Age:50,eyecolor: "Blue"};

6. Creating an object constructor

function person (firstname,lastname,age,eyecolor)

To create an object from the object builder

var myfather=new person ("Bill", "Gates", "a", "Blue");
var mymother=new person ("Steve", "Jobs", "green");

7. Add a method to an existing JavaScript object

function person (firstname,lastname,age,eyecolor)

function ChangeName (name)


JavaScript is an object-oriented language, but JavaScript does not use classes.

In JavaScript, classes are not created and objects are not created through classes.

JavaScript is based on prototype, not class-based.

9. The JavaScript statement iterates through the properties of the object.

var person={fname: "Bill", lname: "Gates", age:56};

for (x in person)
Txt=txt + person[x];

10. With statement: With the WITH statement, you can access object properties and call object methods without specifying the object.

With (object) {


With (document) {
for (var i = 0; i<5; i++) {

for (var j =0; J<=i; j + +) {
Write ("*&nbsp;");
Write ("<br/>");
Write ("}

function person (ID, name) { = ID; = name;

Create an Object
var p = new Person (110, "Dog Doll");

With (p) {
document.write ("Number:" +;
document.write ("Name:" + name);

function Reportreadbyppatientid (Patientid) {
var patientid=$ ("#hiddenpatientId"). Val ();
alert (Patientid);
var url= $WEB _root_path + "/reportread/reportreadctrl.htm? Blhmi=listbypatientid ";
$.post (url,{' Dto.reportReadVo.patientid ': Patientid}, Function () {
$CommonUI. Getdatagrid ("#reportReadList"). DataGrid (' reload ');


1, JS objects, jquery objects to each other transformation
[JS Object-->jquery Object]:var jquery object = $ (JS object);
[jquery Object-->js Object]:var js object = jquery Object [index]
var js object = jquery object. Get (Index)

2. The size () method and the length property are all used to get the number of elements in the jquery object, no difference!

3. The difference between the text () and the HTML () method:
HTML ():
1. Get the HTML content of [first matching element], including tags.
2. If the selector matches more than one element, only the HTML content of the first matching element will be fetched.
3. This function cannot be used in XML documents. But it can be used in XHTML documents.

Text ():
1. Get the text content of [all matching elements], not including the label.
2. If the selector matches more than one element, the result is text that is combined with the text content contained by all matching elements.
3. This method is valid for both HTML and XML documents.

4. The traversal method each () in this refers to the JS object

5. The filtering method in jquery is similar to the selector function, and is used to get specific DOM elements

6, find (): is to find the descendant elements of the specified element, all searches rely on the jquery expression to complete. Similar to the "ancestor descendant" selector


var length = $CommonUI. Getdatagrid (' #doctorOrdersGrid '). DataGrid (' GetRows '). length;

var Editrow = $CommonUI. Getdatagrid (' #doctorOrdersGrid '). DataGrid ("getselected");

var editindex = $CommonUI. Getdatagrid (' #doctorOrdersGrid '). DataGrid ("Getrowindex", Editrow);


A. Get real-time values in an editable state:

$ ($CommonUI. Getdatagrid (' #doctorOrdersGrid '). DataGrid (' Geteditor ', {index:i,field: ' itemid '). Target). Val ()

Equivalent to:

var itemideditor = $CommonUI. Getdatagrid (' #doctorOrdersGrid '). DataGrid (' Geteditor ', {index:i,field: ' itemid '});

$ ( Val ()

B. can be edited off (by EndEdit or AcceptChanges (also close the Edit state) method) to get the value

var rowdata= $CommonUI. Getdatagrid (' #doctorOrdersGrid '). DataGrid ("GetData");

Varitemid = Rowdata.rows[i].itemid;

3. ComboBox whether the data is fetched from the background via a URL, or from the local organization, requires a specific JSON format similar to that required by the DataGrid, {"Total": xx,rows:[{},{},...]}

In fact, the ComboBox gets the data from the background and is put in the Pagemodel to return directly, so that the resulting data format conforms to the above situation

A. Get from the background via a URL:

type of number:<inputclass="ComboBox"type="text"ID="Code"name="CodeType"style="width:120px;Height:20px;"


URL: ' <%=request.getcontextpath ()%>/treatmentnomaintain/treatmentnomaintainctrl.htm?

Blhmi=getcodetype ',

mode: ' Remote ',


Valuefield: ' id ',

TextField: ' Text ', ' />

Background pass-through number type

publicvoid getcodetype (baseabstractdto basedto) {

Treatmentnomaintaindtodto = Supergetexactlydto (basedto);

method that invokes the corresponding service query for an entity

Pagermodel Pm=treatmentnomaintainservice.getcodetype (DTO);

Dto.setpagemodel (PM);


The data format is as follows:

Note: The background passes over the rows attribute (in the entity class or Vo defined in the class) and {Valuefield: ' id ', textField: ' Text '} relative should

b Data generation ComboBox on-premises organization

$ ( ComboBox (' LoadData ', {total:2, rows:[{"ID": Rowdata.baseunitdesc, "text ": Rowdata.baseunitdesc," selected ": True},{"ID": Rowdata.mediunitdesc,"text": ROWDATA.BASEUNITDESC}]});

field values defined in the Dagagrid column:

{field: ' Basicunit ', width:22,align: ' Left ', Editor:{type: ' ComboBox ', Options:{valuefield:' id ', TextField : 'text '}},title: ' Unit '},

"Selected": True indicates that this item is selected by default

4, Combogrid, ComboBox get Value

$ ( Combogrid ("SetValue", rowdata.phaname);

$ ( ComboBox (' SetValue ', rowdata.mediunitdesc);

5. Get the data that the ComboBox obtains from the background


: Return the loaded data.

var freqdata=$ ( ComboBox ("getData");

6. Get Combogrid Focus

$ ( Combogrid (). Next (' span '). FIND (' input '). focus (); (Firebug view element Relationship)

7.String number.toFixed(number dot): Intercept to fixed decimal place

8,JSformat Timeformatterdatetime = function (mydate) {    Y =mydate.getfullyear ();    M =mydate.getmonth () +1<10? " 0 "+ (Mydate.getmonth () +1): Mydate.getmonth () +1;      D =mydate.getdate () <10? " 0 "+mydate.getdate (): Mydate.getdate ();    H =mydate.gethours () <10? " 0 "+mydate.gethours (): Mydate.gethours ();    M =mydate.getminutes () <10? " 0 "+mydate.getminutes (): Mydate.getminutes ();    S =mydate.getseconds () <10? " 0 "+mydate.getseconds (): Mydate.getseconds ();    returny+ '-' +m+ '-' +d+ ' +h+ ': ' +m+ ': ' +s;}; 9, turn on Edit status (select First, then turn on)A $ (' #chinaMedicineGrid '). DataGrid (' SelectRow ', i);b. $ (' #chinaMedicineGrid '). DataGrid (' BeginEdit ', i);  .ClearDataGridthe Data$CommonUI. Getdatagrid (' #materialGrid '). DataGrid ("LoadData", {"Total": "0", "Rows": []}); One by one .AshCombogrid(Combogridcan be called directlyComboin the method)two ways to place AshEasyuicomponents:1.components that are provided in theDisableMethod:For exampleCombo,Numberboxetc. (by checkingWebUI API)varexamnameeditor = $ (' #examGrid '). DataGrid (' Geteditor ', {index:i,field: ' Examname '});$ ({disabled:true}); ForCombogrid DOM(JS) Object2.JQueryin the property setting method (Editortype istext):

Varamounttotaleditor = $ (' #examGrid '). DataGrid (' Geteditor ', {index:i,field: ' Examsalesprice '});

$ ( attr ({"Disabled": true});

12. Assign data from the background directly to the foreground datagrid

$ (' #examGrid '). DataGrid (' LoadData ', msg);

Note: The MSG data format is Pagemodel format, which is {"Total": xx,rows[{},{},...]}

Project front End Knowledge Point Summary 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.