. NET MvC3 + easyui DataGrid get single page data no refresh paging

Source: Internet
Author: User
HTML:

Code Replication-Running

<table id= "DataList" ></table>

JQuery Easyui:

Code Replication-Running

$ (' #dataList '). DataGrid ({ 
        title: ' Paging Data ',   //title
        iconcls: ' Icon-save ',  //Table icon
        width:500,  / /table Width
        height:300,//   table height
        pagesize:15,//per page display quantity
        pagelist: [15, 30, 45],///You can set the list URL for the number of record bars per page 
        : '/ Home/getlist ',//MVC controllers address
        sortname: ' ID ',//  field to sort
        sortOrder: ' desc ',//  sorting rules
        Singleselect:true,  //Only select single line
        pagination:true  //Here must be set to true
    }); 
    var p = $ (' #datList '). DataGrid (' Getpager '); 
    P.pagination ({ 
        beforepagetext: ' First ', the kanji displayed before//page text box           
        afterpagetext: ' pages    total {pages} ',           
        displaymsg: ' The {from}-{to} record is currently displayed (   total} record ' 
    }]; 



C #:

Code Replication-Running

Background database Paging public Jsonresult getlist () {try {string rows = R equest["Rows"].  ToString (); Gets the number of rows from the DataGrid string page = request["page". ToString (); Get the page number//current page int intpage = int from the DataGrid. Parse ((page = null | | | page = = "0")? 
                "1": page); The number of bars per page int = Int. Parse (rows = NULL | | rows = "0")? 
                "Ten": rows); 
                The start record for each page is 1 page two for number +1 int start = (intPage-1) * number;  var TB = dt.listpage (number, start); 
                DT For Models Datacontext,listpage is a stored procedure var jsonmap = new dictionary<string, object> (); 
                Jsonmap.add ("Total", count ()); 
                Jsonmap.add ("Rows", TB); 
            Return Json (Jsonmap, jsonrequestbehavior.allowget); 
            catch {return null;
  }}     private int count () {try {var TB = from DB in dt.table
                Select DB; Return TB.
            Count ();
            catch {return 0;
 }
        }

SQL stored procedures:

Code Replication-Running

CREATE PROCEDURE listpage 
@number int, 
@start int 
as 
select Top (@number) * FROM table where (ID no in (SE Lect Top (@start) ID from table order BY id DESC) desc
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.