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