Jqgrid functions seem to be good, but most of them are in the php environment. If you are bored, here we are tossing the form of returning json data ..
First, there is a picture with truth ..
Create an html page
Introduce the relevant resource file, <script src = "i18n/grid. locale-cn.js "type =" text/javascript "> </script> for the local file, each parameter detailed information is not much said, try to know ..
Hd. aspx processes the File Code. There is no value judgment or access to the database here. It just simulates it, so it does not implement the sorting function. You can flip the page and modify the background program for specific functions, it will pass the corresponding parameters to you ..
View sourceprint? Namespace WebDevelop. js. lib. jq. grid
{
Public partial class hd: System. Web. UI. Page
{
Protected void Page_Load (object sender, EventArgs e)
{
Int page = Convert. ToInt32 (Request. QueryString ["page"]); // you can specify the page to display.
Int rows = Convert. ToInt32 (Request. QueryString ["rows"]); // you can specify the number of rows to display.
// String sidx = Request. QueryString ["sidx"]; // field name to be sorted
// String sord = Request. QueryString ["sord"]; // in ascending or descending order
Response. Write (jsonstring (page, rows, 30 ));
Response. End ();
}
Private string jsonstring (int page, int rows, double records)
{
Double a = records/rows;
Int total = Convert. ToInt32 (Math. Ceiling (a); // total number of pages
StringBuilder sb = new StringBuilder ("{");
Sb. appendFormat (@ "" page "": "" {0} "", "" total "": {1}, "" records "": "" {2} "", "" rows "": {3} ", page, total, records, createrows (rows * (page-1 ), rows * page ));
Sb. Append ("}");
Return sb. ToString ();
}
Private string createrows (int pageS, int pageE)
{
StringBuilder s = new StringBuilder ("[");
For (; pageS <pageE; pageS ++)
{
S. Append ("{");
S. appendFormat (@ "" id "": "" {0} "", "cell": ["{1 }"", "" {2} "", "" {3} "", "" {4} "", "" {5} "", "" {6 }"", "" {7} ""] ", pageS + 1, pageS + 1, DateTime. now. toString (), "ClientXXX", "10000.0", "0.000", "1000", null );
If (pageS! = PageE-1)
S. Append ("},");
}
S. Append ("}]");
Return s. ToString ();
}
}
}