jquery分頁(yè)插件jquery.pagination.js實(shí)現(xiàn)無(wú)刷新分頁(yè)
本文實(shí)例為大家分享了jquery分頁(yè)插件實(shí)現(xiàn)無(wú)刷新分頁(yè)的相關(guān)代碼,供大家參考,具體內(nèi)容如下
1.使用插件為 jquery.pagination.js ,如果沒有這個(gè)js文件的話,我可以給發(fā)個(gè)。
首先引用 jquery.pagination.js (分頁(yè)js),跟pagination.css(分頁(yè)樣式css)。
2.頁(yè)面js代碼為
<script type="text/javascript">
var pageIndex = 0; //頁(yè)面索引初始值
var pageSize = 15; //每頁(yè)顯示條數(shù)初始化,修改顯示條數(shù),修改這里即可
$(function () {
InitTable(0); //Load事件,初始化表格數(shù)據(jù),頁(yè)面索引為0(第一頁(yè))
//分頁(yè),PageCount是總條目數(shù),這是必選參數(shù),其它參數(shù)都是可選
$("#Pagination").pagination(<%=pcount%>, {
callback: PageCallback, //PageCallback() 為翻頁(yè)調(diào)用次函數(shù)。
prev_text: "« 上一頁(yè)",
next_text: "下一頁(yè) »",
items_per_page:pageSize,
num_edge_entries: 2, //兩側(cè)首尾分頁(yè)條目數(shù)
num_display_entries: 6, //連續(xù)分頁(yè)主體部分分頁(yè)條目數(shù)
current_page: pageIndex, //當(dāng)前頁(yè)索引
});
//翻頁(yè)調(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(頁(yè)面索引),pageSize(顯示條數(shù))
success: function(data) {
$("#Result tr:gt(0)").remove(); //移除Id為Result的表格里的行,從第二行開始(這里根據(jù)頁(yè)面布局不同頁(yè)變)
$("#Result").append(data); //將返回的數(shù)據(jù)追加到表格
}
});
}
});
</script>
3.頁(yè)面<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.頁(yè)面后臺(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 + "'"); //獲取頁(yè)面總條數(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 的摘要說(shuō)明
/// </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; //具體的頁(yè)面數(shù)
int.TryParse(context.Request["pageIndex"], out pageIndex);
if(context.Request["pageSize"]!=null&&context.Request["pageSize"].ToString().Length > 0)
{
//頁(yè)面顯示條數(shù)
int size = Convert.ToInt32(context.Request["pageSize"]);
string data= BindSource(size,pageIndex);
context.Response.Write(data);
context.Response.End();
}
}
}
#region 無(wú)刷新分頁(yè)
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)分頁(yè)示例
- jQuery分頁(yè)插件jquery.pagination.js使用方法解析
- jquery分頁(yè)插件jquery.pagination.js使用方法解析
- asp.net jquery無(wú)刷新分頁(yè)插件(jquery.pagination.js)
- jquery.pagination.js 無(wú)刷新分頁(yè)實(shí)現(xiàn)步驟分享
- jQuery EasyUI API 中文文檔 - Pagination分頁(yè)
- jQuery Pagination Ajax分頁(yè)插件(分頁(yè)切換時(shí)無(wú)刷新與延遲)中文翻譯版
- jquery pagination插件實(shí)現(xiàn)無(wú)刷新分頁(yè)代碼
- Ajax分頁(yè)插件Pagination從前臺(tái)jQuery到后端java總結(jié)
- jquery.pagination.js分頁(yè)使用教程
相關(guān)文章
jquery實(shí)現(xiàn)移動(dòng)端按鈕組左右滑動(dòng)
這篇文章主要為大家詳細(xì)介紹了jquery實(shí)現(xiàn)移動(dòng)端按鈕組左右滑動(dòng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-03-03
Jquery通過(guò)JSON字符串創(chuàng)建JSON對(duì)象
這篇文章主要介紹了Jquery如何通過(guò)JSON字符串創(chuàng)建JSON對(duì)象,并附詳細(xì)示例,需要的朋友可以參考下2014-08-08
jCallout 輕松實(shí)現(xiàn)氣泡提示功能
在提交表單前、焦點(diǎn)轉(zhuǎn)移后或者 keyup 時(shí)往往需要對(duì)輸入的文本就行檢驗(yàn),如果輸入內(nèi)容不符合相關(guān)約定則要進(jìn)行提示或警告,有一個(gè)叫 jCallout 的插件可以輕松實(shí)現(xiàn)該功能,該插件基于 jQuery 使用,所以使用前需要添加引用 jQuery2013-09-09
實(shí)現(xiàn)placeholder效果的方案匯總
由于placeholder是html5的新屬性,可想而知,僅支持html5的瀏覽器才支持placeholder,目前最新的firefox、chrome、safari以及ie10都支持,ie6到ie9都不支持。2015-06-06
jquery 圖片Silhouette Fadeins漸顯效果
經(jīng)常漂流在css-tricks看到這篇文章,就順便搬了過(guò)來(lái),下面譯文都是用css-tricks口吻來(lái)描述的。2010-02-02
jquery checkbox,radio是否選中的判斷代碼
jquery checkbox,radio是否選中的判斷代碼,需要的朋友可以參考下。2010-03-03
jQuery+CSS3實(shí)現(xiàn)四種應(yīng)用廣泛的導(dǎo)航條制作實(shí)例詳解
這篇文章主要介紹了jQuery+CSS3實(shí)現(xiàn)多種類型的導(dǎo)航條制作實(shí)例詳解的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-09-09
jQuery中需要注意的細(xì)節(jié)問(wèn)題小結(jié)
jQuery中需要注意的細(xì)節(jié)問(wèn)題小結(jié),使用jquery的朋友可以參考下。2011-12-12

