jquery分頁插件jquery.pagination.js實(shí)現(xiàn)無刷新分頁
本文實(shí)例為大家分享了jquery分頁插件實(shí)現(xiàn)無刷新分頁的相關(guān)代碼,供大家參考,具體內(nèi)容如下
1.使用插件為 jquery.pagination.js ,如果沒有這個(gè)js文件的話,我可以給發(fā)個(gè)。
首先引用 jquery.pagination.js (分頁js),跟pagination.css(分頁樣式css)。
2.頁面js代碼為
<script type="text/javascript">
var pageIndex = 0; //頁面索引初始值
var pageSize = 15; //每頁顯示條數(shù)初始化,修改顯示條數(shù),修改這里即可
$(function () {
InitTable(0); //Load事件,初始化表格數(shù)據(jù),頁面索引為0(第一頁)
//分頁,PageCount是總條目數(shù),這是必選參數(shù),其它參數(shù)都是可選
$("#Pagination").pagination(<%=pcount%>, {
callback: PageCallback, //PageCallback() 為翻頁調(diào)用次函數(shù)。
prev_text: "« 上一頁",
next_text: "下一頁 »",
items_per_page:pageSize,
num_edge_entries: 2, //兩側(cè)首尾分頁條目數(shù)
num_display_entries: 6, //連續(xù)分頁主體部分分頁條目數(shù)
current_page: pageIndex, //當(dāng)前頁索引
});
//翻頁調(diào)用
function PageCallback(index, jq) {
InitTable(index);
}
//請(qǐng)求數(shù)據(jù)
function InitTable(pageIndex) {
$.ajax({
type: "POST",
dataType: "text",
url: 'http://www.cnblogs.com/tool/Reserver/ManageBuyBatchManage.ashx', //提交到一般處理程序請(qǐng)求數(shù)據(jù)
data: "pageIndex=" + (pageIndex) + "&pageSize=" + pageSize, //提交兩個(gè)參數(shù):pageIndex(頁面索引),pageSize(顯示條數(shù))
success: function(data) {
$("#Result tr:gt(0)").remove(); //移除Id為Result的表格里的行,從第二行開始(這里根據(jù)頁面布局不同頁變)
$("#Result").append(data); //將返回的數(shù)據(jù)追加到表格
}
});
}
});
</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 > </td>
</tr>
</table>
<table id="Result" cellspacing="0" cellpadding="0">
<tr>
<th>商品編號(hào)</th>
<th>商品名稱</th>
</tr>
</table>
<div id="Pagination" class="right flickr"></div>
4.頁面后臺(tái)代碼為
protected int pcount = 0; //總條數(shù)
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BLL.TbGoods bll = new BLL.TbGoods();
pcount = bll.GetRecordCount("Status='" + (int)Enum.RecordStatus.Normal + "'"); //獲取頁面總條數(shù),即要現(xiàn)實(shí)的數(shù)據(jù)總條數(shù),還不明白的話,就是select count(*)from Table ,就是這里的個(gè)數(shù)。
}
}
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; //具體的頁面數(shù)
int.TryParse(context.Request["pageIndex"], out pageIndex);
if(context.Request["pageSize"]!=null&&context.Request["pageSize"].ToString().Length > 0)
{
//頁面顯示條數(shù)
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)); //獲取數(shù)據(jù)源的ds會(huì)吧。
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.效果圖

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助。
- Spring Data Jpa+SpringMVC+Jquery.pagination.js實(shí)現(xiàn)分頁示例
- jQuery分頁插件jquery.pagination.js使用方法解析
- jquery分頁插件jquery.pagination.js使用方法解析
- asp.net jquery無刷新分頁插件(jquery.pagination.js)
- jquery.pagination.js 無刷新分頁實(shí)現(xiàn)步驟分享
- jQuery EasyUI API 中文文檔 - Pagination分頁
- jQuery Pagination Ajax分頁插件(分頁切換時(shí)無刷新與延遲)中文翻譯版
- jquery pagination插件實(shí)現(xiàn)無刷新分頁代碼
- Ajax分頁插件Pagination從前臺(tái)jQuery到后端java總結(jié)
- jquery.pagination.js分頁使用教程
相關(guān)文章
jquery超簡(jiǎn)單實(shí)現(xiàn)手風(fēng)琴效果的方法
這篇文章主要介紹了jquery超簡(jiǎn)單實(shí)現(xiàn)手風(fēng)琴效果的方法,只需要幾行代碼即可實(shí)現(xiàn)手風(fēng)琴效果的樣式變換功能,需要的朋友可以參考下2015-06-06
jquery提示 "object expected"的解決方法
在測(cè)試代碼的時(shí)候,提示object expected,下面的解決方法,可以參考下。2009-12-12
淺談jquery回調(diào)函數(shù)callback的使用
這篇文章主要簡(jiǎn)單介紹了jquery回調(diào)函數(shù)callback的使用,需要的朋友可以參考下2015-01-01
jquery判斷小數(shù)點(diǎn)兩位和自動(dòng)刪除小數(shù)兩位后的數(shù)字
這篇文章主要介紹了jquery判斷小數(shù)點(diǎn)兩位和自動(dòng)刪除小數(shù)兩位后的數(shù)字,需要的朋友可以參考下2014-03-03
基于jquery實(shí)現(xiàn)彩色投票進(jìn)度條代碼解析
這篇文章主要介紹了基于jquery實(shí)現(xiàn)彩色投票進(jìn)度條代碼解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-08-08
基于jQuery實(shí)現(xiàn)頂部導(dǎo)航欄功能
這篇文章主要為大家詳細(xì)介紹了基于jQuery實(shí)現(xiàn)頂部導(dǎo)航欄功能,jQuery三級(jí)下拉列表導(dǎo)航菜單,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-12-12
jQuery UI AutoComplete 自動(dòng)完成使用小記
jQuery UI AutoComplete 自動(dòng)完成使用小記,使用jquery的朋友實(shí)現(xiàn)搜索自動(dòng)完成等功能的朋友可以參考下。2010-08-08
jquery京東商城雙11焦點(diǎn)圖多圖廣告特效代碼分享
這篇文章主要介紹了jquery京東商城雙11焦點(diǎn)圖多圖廣告特效,一個(gè)精致的焦點(diǎn)圖會(huì)吸引用戶的注意力,讓用戶產(chǎn)生瀏覽網(wǎng)站的興趣至關(guān)重要,現(xiàn)在小編推薦給大家一款特別棒的焦點(diǎn)圖,感興趣的小伙伴可以參考下。2015-09-09
jQuery EasyUI 組件加上“清除”功能實(shí)例詳解
在使用 EasyUI 各表單組件時(shí),尤其是使用 ComboBox(下拉列表框)、DateBox(日期輸入框)、DateTimeBox(日期時(shí)間輸入框)這三個(gè)組件時(shí),經(jīng)常會(huì)遇到下拉框或日期只允許選擇、不允許手動(dòng)輸入功能,怎么解決呢,下面小編給大家分享解決方案,一起看看吧2017-04-04

