Use of jqgrid in. net

Source: Internet
Author: User
Tags jqgrid

 

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 ();

 

}

}

}

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.