Easy ui datagrid data Paging

Source: Internet
Author: User

I wrote a datagrid data paging demo by referring to the demo provided on the easyui official website,

I will not list the specific parameters one by one. For details, refer to the official website,

Here we will only introduce the specific precautions and frequently used items,

1 $ ('# test'). datagrid ({2 iconCls: 'icon-save', 3 nowrap: false, 4 striped: true, 5 url: 'userhandler. ashx? Action = list', 6 title: 'regionird', 7 loadMsg: "loading. Please wait... ", 8 width: 350, 9 height:, 10 singleSelect: true, 11 columns: [[12 {field: 'username', title: 'number', width: 80 }, 13 {field: 'Password', title: 'name', width: 100}, 14], 15 16 pagination: true, 17 rownumbers: true18 });

The specific columns are 11 to 14 rows in the Code. The UserName and Password correspond to the keys in the json string,
Note: "pagination: true" must be explicitly added. The default value is false,

Let's look at the server:

1 int pageSize = 10; // get pageSize 2 int pageNum = 0 through this query; // get pageNum 3 4 if (Request ["page"]! = Null) 5 {6 int. TryParse (Request ["page"], out pageNum); 7} 8 9 if (Request ["rows"]! = Null) 10 {11 int. tryParse (Request ["rows"], out pageSize); 12} 13 14 string resultStr = ""; 15 16 resultStr + = "{\" total \ ":" + lsFileType. count + ", \" rows \ ": ["; 17 for (int I = (pageNum-1) * pageSize; I <pageSize; I ++) 18 {19 resultStr + = "{"; 20 resultStr + = string. format ("\" UserName \ ": \" {0} \ ", \" Password \ ": \" {1} \ "", lsFileType [I]. userName, lsFileType [I]. password); 21 resultStr + = "},"; 22} 23 resultStr = resultStr. substring (0, resultStr. length-1); 24 resultStr + = "]}";

Note that the total and rows parameters must be enclosed in quotation marks,
ResultStr + = "{total:" + lsFileType. Count + ", rows :[";

No data is displayed.

Download demo

 

 

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.