[Switch] jqgrid learning data

Source: Internet
Author: User
Tags jqgrid

Data Types supported by jqgrid: XML, JSON, jsonp, local or clientside, xmlstring, and jsonstring
, Script, function (...).

 

JSON data

Jsonreader needs to be defined to correspond to the data returned by the server. Its default value is:

· Jsonreader :{

· Root: "rows ",

· Page: "page ",

· Total: "Total ",

· Records: "records ",

· Repeatitems: True,

· Cell: "cell ",

· ID: "ID ",

· Userdata: "userdata ",

· Subgrid: {root: "rows ",

· Repeatitems: True,

· Cell: "cell"

·}

 

The data format returned by the server is as follows:

·{

· Total: "XXX ",

· Page: "yyy ",

· Records: "Zzz ",

· Rows :[

· {ID: "1", cell: ["cell11", "cell12", "cell13"]},

· {ID: "2", cell: ["cell21", "cell22", "cell23"]},

·...

·]

·}

Jsonreader attributes

Total

Total number of pages

Page

Current page

Records

Number of records queried

Rows

Array containing actual data

ID

Row ID

Cell

All cells in the current row

 

Custom:

· Jquery ("# gridid"). jqgrid ({

·...

· Jsonreader :{

· Root: "invdata ",

· Page: "currpage ",

· Total: "totalpages ",

· Records: "totalrecords ",

· Cell: "invrow"

·},

·...

·});

· Totalpages: "XXX ",

· Currpage: "yyy ",

· Totalrecords: "Zzz ",

· Invdata :[

· {ID: "1", invrow: ["cell11", "cell12", "cell13"]},

· {ID: "2", invrow: ["cell21", "cell22", "cell23"]},

·...

·]

Repeatitems
It indicates that the data in each row can be repeated. If it is set to false, the elements will be searched by name from the returned data. This name is the name in colmodel.

· Jsonreader :{

· Root: "invdata ",

· Page: "currpage ",

· Total: "totalpages ",

· Records: "totalrecords ",

· Repeatitems: false,

· ID: "0"

·}

· Totalpages: "XXX ",

· Currpage: "yyy ",

· Totalrecords: "Zzz ",

· Invdata :[

· {Invid: "1", invdate: "cell11", amount: "cell12", tax: "cell13", total: "1234", note: "somenote "},

· {Invid: "2", invdate: "cell21", amount: "cell22", tax: "cell23", total: "2345", note: "Some note "},

·...

·]

In this example, the property value of ID is "Invid ".
Once this attribute is set to false, we do not need to assign values to all the name values defined in colmodel. Because the element is searched by name, the sorting result is not specified by colmodel.

User Data)
In some cases, we need to return some parameters from the server, but do not want to directly display them in the Table. Instead, we want to display them elsewhere. Then we need to use the userdata tag.

· Jsonreader :{

·...

· Userdata: "userdata ",

·...

·}

·{

· Total: "XXX ",

· Page: "yyy ",

· Records: "Zzz ",

· Userdata: {totalinvoice: 240.00, tax: 40.00 },

· Rows :[

· {ID: "1", cell: ["cell11", "cell12", "cell13"]},

· {ID: "2", cell: ["cell21", "cell22", "cell23"]},

·...

·]

·}

On the client side, we can obtain the additional information in the following two ways:

1. jquery ("grid_id"). getgridparam ('userdata ')

2. jquery ("grid_id"). getuserdata ()

3. jquery ("grid_id"). getuserdataitem (key)

[Switch] jqgrid learning data

Related Article

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: info-contact@alibabacloud.com 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.