LigerUI paging MVC and ligerui paging mvc

Source: Internet
Author: User

LigerUI paging MVC and ligerui paging mvc

Javascirpt code

$ ("# ShowData "). ligerGrid ({columns: [{display: 'number', name: 'l _ id', align: 'center', width: 70}, {display: 'time ', name: 'l _ time', minWidth: 120, type: 'date', format: 'yyyy-MM-dd HH: mm'}, {display: 'longitude ', name: 'l _ longning', width: 90, align: 'left'}, {display: 'latitude ', name: 'l _ LATITUDE', width: 80, align: 'left'}, {display: 'intensity ', name: 'l _ current', width: 50}, {display: 'Return quantity', name: 'l _ RETI MES ', width: 50}, {display: 'number of positioning stations', name: 'l _ stationnum', width: 50}], // bind the header of the corresponding column, you can set/data: dataList, // data url :'.. /.. /LightningSearch/GetLightningByTime? Stime = '+ $ ("# txtStime "). val () + '& etime =' + $ ("# txtEtime "). val () + '', pageSizeOptions: [10, 20, 30,], pageSize: 15, // how many pieces of data are displayed on each page sortName: 'l _ id ', // sort width: 'auto' in that column, // width height: '000000', dateFormat: 'yyyy-MM-dd HH: mm', checkbox: false // whether a selection box exists });View Code

ActionResult

Public ActionResult GetLightningByTime () {// int page = Convert. toInt32 (Request. params ["page"]); // number of records displayed per page int pageSize = Convert. toInt32 (Request. params ["pagesize"]); string stime = Request. params ["stime"]. toString (); string etime = Request. params ["etime"]. toString (); string _ stime = stime. replace ("-",""). replace (":",""). replace ("", "") + "00"; string _ etime = etime. replace ("-",""). replace (":",""). replace ("", "") + "59"; LightningL19XX list = helper. getLightningByTime (_ stime, _ etime, page, pageSize); int count = list. _ Count; List <L19XX> lightning = list. _ L19XX; var gridData = new {Rows = lightning, Total = count}; return Json (gridData );}View Code

Paging (the table structure of the database is consistent, and the table name is "L" + Year)

Public LightningL19XX GetLightningByTime (string stime, string etime, int page, int pageSize) {List <L19XX> list = new List <L19XX> (); int _ stime = int. parse (stime. substring (0, 4); int _ etime = int. parse (etime. substring (0, 4); string _ TableName = "L"; int _ count = _ etime-_ stime; string SQL = ""; for (int I = _ stime; I <= _ etime; I ++) {if (_ etime> I) {SQL + = "select * from" + _ TableName + I. toString () + "where L_TIME> =" + stime + "and L_TIME <=" + etime + "union ";} else {SQL + = "select * from" + _ TableName + I. toString () + "where L_TIME> =" + stime + "and l_TIME <=" + etime + "" ;}} int count = entity. database. sqlQuery <L19XX> (SQL ). toList (). count; list = entity. database. sqlQuery <L19XX> (SQL ). toList (). skip (page-1) * pageSize ). take (pageSize ). toList (); if (list. count = 0) {L19XX l = new L19XX () {L_ALTITUDE = null, L_CURRENT = null, L_RETIMES = null, l_longpolling = null, L_TIME = null, L_LATITUDE = null, rochelle id = null}; list. add (l);} LightningL19XX lightning = new LightningL19XX () {_ L19XX = list, _ Count = count}; return lightning ;}View Code

 


How does ligerui implement server paging?

Ligerui
Paging is supported by the server, as long as the server obtains the paging information, such as the page size, page number

Www.ligerui.com/api/document/Grid/parms.htm
 
How does ligerui obtain all data in a paging table?

LigerUI provides two paging Methods: local and server.

If the data volume is not large, use local paging to send all the data to the foreground at a time. Then, the grid of LigerUI will automatically pagination. Let's talk about total. When jsonString is transmitted in the background, the defined total (total number of items) can be transmitted. You can define the total number, but at the foreground, it will automatically assign the total number to total, this is the local method.

If the data volume is large and the data is not displayed or the response is slow during one-time loading, the server page is used. When the server page is used, each request will send two more parameters than local: page and pagesize. You do not need to send them by yourself. You only need to obtain them in the background,

Int page = Integer. parseInt (request. getParameter ("page "));

Int pagesize = Integer. parseInt (request. getParameter ("pagesize "));

Int total;

In this case, you can write the page and pagesize into your SQL statement:

SQL = ".........";

SQL + = "limit" + (page * pagesize-pagesize) + "," + pagesize;

In this way, the result is put into the jsonString. Pay attention to total here. total needs to be defined by yourself. You need to re-check the total number of results and assign the value to total to pass to the page, other LigerUI will help you!

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.