Jquery-pager Sub-page

Source: Internet
Author: User

First refer to these three files

<script src= ". /.. /scripts/jquery-1.4.4.min.js "type=" Text/javascript "></script>
<script src= ". /.. /scripts/jquery-pager-1.0.js "type=" Text/javascript "></script>
<link href= ". /.. /scripts/pager.css "rel=" stylesheet "type=" Text/css "/>


<Body> <Div> <Divclass= "title"> <H1>Workload Statistics</H1> </Div> <Tablewidth= "50%"Border= "1"class= "T1"> <thead> <th>Tomb Type Code</th> <th>Tomb type name</th> <th>Area</th> <th>Unit Price</th> <th>Cumulative Tomb Building</th> </thead> <tbodystyle= "text-align:center; font-size:12px; color:black;"> </tbody> </Table> <BR/> <DivID= "Page-bottom"style= "width:55%; border:1px;"class= "PageInfo"> </Div> </Div></Body>

Front-End Code:

<script language= "javascript" type= "Text/javascript" >//get total page data        functionGetpagecount () {varresult = ""; $.ajax ({type:"POST", URL:"/manager/workstatistic/pagegetcount", Cache:"False", Async:false, Success:function(data) {result=eval (data); }, Error:function(XMLHttpRequest, Textstatus, Errorthrown) {alert ("Program Exception!");            }            }); returnresult;        }; $ (document). Ready (function () {            //load pages and page numbers            varRecordCount =Getpagecount (); Initpager (RecordCount,1);        }); functionInit (PageIndex, PageCount) {varReceive_url = "/manager/workstatistic/workstatistics?pageindex=" + PageIndex + "&pagecount=" +PageCount; $.ajax ({type:"GET", Url:receive_url, cache:"False", Success:function(data) {data=eval (data); $("Tbody"). HTML (""); varhtml = "";  for(vari = 0; i < data.length; i++) {                        varJSON =Data[i]; varMXDM =Json.mxdm; varMXDMMC =Json.mxdmmc; varMJ =JSON.MJ; varDJ =Json.dj; varLJJM =JSON.LJJM; HTML+ = "<tr><td>" + Mxdm + "</td><td>" + Mxdmmc + "</td><td>" + MJ + "</td><td&gt ; "+ DJ +" </td><td> "+ LJJM +" </td></tr> "; }                    $("Tbody"). append (HTML); }, Error:function(XMLHttpRequest, Textstatus, Errorthrown) {alert ("Program Exception!");        }            });        }; //recordcount[total number of records] pageindex[current page]        functionInitpager (RecordCount, PageIndex) {$ ("#page-bottom"). Setpager ({recordcount:recordcount, Pageindex:pageindex, Buttonclick:pageclick}); //Update data sources at the same time by pagingInit (PageIndex, 20);        }; //Paging EventsPageclick =function(RecordCount, PageIndex) {Initpager (RecordCount, PageIndex);    }; </script>

Client code:

         PublicActionResult Workstatistics () {stringPageIndex = Request.Params.Get ("PageIndex"); stringPageCount = Request.Params.Get ("PageCount"); intpage = Convert.ToInt32 (pageIndex) *Convert.ToInt32 (PageCount); stringSql_init =@"SELECT * FROM (select RowNum rn,t.* from (select A.mxdm,a.mxdmmc,a.mj,avg (select DJ from Mxdm WHERE a.mxdm= mxdm) Dj,count (*) LJJM"+"From mwdmxx a where a.azfsdm= ' down ' GROUP by A.mxdm, A.MXDMMC,A.MJ ORDER by A.mxdm) t where rownum <="+ page +") WHERE RN >"+ (Page-Convert.ToInt32 (PageCount)); DataSet DS=dbhelper.query (Sql_init); //instantiating an array of struct bodiesTombtype_saleinfo[] result =NewTombtype_saleinfo[ds. tables[0].            Rows.Count];  for(inti =0; I < DS. tables[0]. Rows.Count; i++)            {                stringMxdm = ds. tables[0]. rows[i]["Mxdm"].                ToString (); stringMxdmmc = ds. tables[0]. rows[i]["Mxdmmc"].                ToString (); DoubleMJ = Double.Parse (ds. tables[0]. rows[i]["MJ"]. ToString () = =""?"0": DS. tables[0]. rows[i]["MJ"].                ToString ()); intdj = Int32.Parse (ds. tables[0]. rows[i]["DJ"]. ToString () = =""?"0": DS. tables[0]. rows[i]["DJ"].                ToString ()); intLJJM = Int32.Parse (ds. tables[0]. rows[i]["LJJM"]. ToString () = =""?"0": DS. tables[0]. rows[i]["LJJM"].                ToString ()); Tombtype_saleinfo Temp=NewTombtype_saleinfo (MXDM, MXDMMC, MJ, DJ, LJJM); Result[i]=temp; }            returnJson (result, jsonrequestbehavior.allowget); }//Get the total number of data bars Public voidPagegetcount () {stringSql_init =@"Select COUNT (*) from (select count (A.MXDM) from Mwdmxx a WHERE a.azfsdm= ' "GROUP by A.mxdm, A.MXDMMC,A.MJ)"; stringCount =dbhelper.getscalar (Sql_init);            Response.Write (count);        Response.End (); }

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.