無重新整理分頁 jquery.pagination.js

來源:互聯網
上載者:User

標籤:style   blog   http   io   color   ar   os   使用   java   

1.使用外掛程式為 jquery.pagination.js ,如果沒有這個js檔案的話,我可以給發個。

首先引用 jquery.pagination.js (分頁js),跟pagination.css(分頁樣式css)。

 點擊擷取查看這兩個檔案

2.頁面js代碼為 

 

<script type="text/javascript">          var pageIndex = 0;     //頁面索引初始值 var pageSize = 15; //每頁顯示條數初始化,修改顯示條數,修改這裡即可  $(function () { InitTable(0); //Load事件,初始化表格式資料,頁面索引為0(第一頁) //分頁,PageCount是總條目數,這是必選參數,其它參數都是可選 $("#Pagination").pagination(<%=pcount%>, { callback: PageCallback, //PageCallback() 為翻頁調用次函數。 prev_text: "« 上一頁", next_text: "下一頁 »", items_per_page:pageSize, num_edge_entries: 2, //兩側首尾分頁條目數 num_display_entries: 6, //連續分頁主體部分分頁條目數 current_page: pageIndex, //當前頁索引 }); //翻頁調用  function PageCallback(index, jq) { InitTable(index); } //請求資料  function InitTable(pageIndex) { $.ajax({ type: "POST", dataType: "text", url: ‘http://www.cnblogs.com/tool/Reserver/ManageBuyBatchManage.ashx‘, //提交到一般處理常式請求資料 data: "pageIndex=" + (pageIndex) + "&pageSize=" + pageSize, //提交兩個參數:pageIndex(頁面索引),pageSize(顯示條數)  success: function(data) { $("#Result tr:gt(0)").remove(); //移除Id為Result的表格裡的行,從第二行開始(這雷根據頁面配置不同頁變) $("#Result").append(data); //將返回的資料追加到表格  } }); } }); </script>

 

 

 

 

 

3.頁面<body>裡面的代碼為

 

 

 <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="60" align="right">商品名:</td> <td width="200" align="left"><input type="text" id="txtKeywords" class="keyword" /></td> <td width="200" align="left"><input id="search" type="button" value=" 查 找 " class="submit" /></td> <td >&nbsp;</td> </tr> </table> <table id="Result" cellspacing="0" cellpadding="0"> <tr> <th>商品編號</th> <th>商品名稱</th> </tr> </table> <div id="Pagination" class="right flickr"></div> 

 

 

 

 

 

4.頁面後台代碼為

 

 

        protected int pcount = 0;           //總條數        protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BLL.TbGoods bll = new BLL.TbGoods(); pcount = bll.GetRecordCount("Status=‘" + (int)Enum.RecordStatus.Normal + "‘"); //擷取頁面總條數,即要現實的資料總條數,還不明白的話,就是select count(*)from Table ,就是這裡的個數。 } }

 

 

 

5.一般處理常式fffff.ashx代碼為

 

 

using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Text;using System.Data;namespace EShop.Web.Admin.tool.Reserver{ /// <summary> /// ListBuyBatchManage 的摘要說明 /// </summary> public class ListBuyBatchManage : IHttpHandler { public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; String str = string.Empty; if (context.Request["pageIndex"] != null && context.Request["pageIndex"].ToString().Length > 0) { int pageIndex; //具體的頁面數 int.TryParse(context.Request["pageIndex"], out pageIndex); if(context.Request["pageSize"]!=null&&context.Request["pageSize"].ToString().Length > 0) { //頁面顯示條數 int size = Convert.ToInt32(context.Request["pageSize"]); string data= BindSource(size,pageIndex); context.Response.Write(data); context.Response.End(); } } } #region 無重新整理分頁 public string BindSource(int pagesize,int page) { BLL.TbGoods bll=new BLL.TbGoods(); DataSet ds = bll.GetListByPage("Status=‘" + (int)Enum.RecordStatus.Normal + "‘", "", pagesize * page + 1, pagesize * (page + 1)); //擷取資料來源的ds會吧。 StringBuilder sb = new StringBuilder(); if (ds!=null) { foreach (DataRow row in ds.Tables[0].Rows) { sb.Append("<tr><td>"); sb.Append(row["GoodsUid"]); sb.Append("</td><td>"); sb.Append(row["GoodsName"]); sb.Append("</td></tr>"); } } return sb.ToString(); } #endregion public bool IsReusable { get { return false; } } }}

 

 

6.

 

 

 

 

無重新整理分頁 jquery.pagination.js

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.