怎么在jquery中使用pagination.js實(shí)現(xiàn)分頁(yè)?針對(duì)這個(gè)問(wèn)題,這篇文章詳細(xì)介紹了相對(duì)應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問(wèn)題的小伙伴找到更簡(jiǎn)單易行的方法。

添加下載的js和樣式,主要是先添加jquery.js 再添加jquery.pagination.js,我這是下載好的,放在本地
<link rel="stylesheet" href="<%=path%>css/pagination.css" type="text/css"> <script type="text/javascript" src="<%=path%>js/jquery-1.11.3.js"></script> <script type="text/javascript" src="<%=path%>js/jquery.pagination.js"></script>
表格,用的是c標(biāo)簽,獲取控制器傳過(guò)來(lái)的值
<table width="1052" border=0 align=center cellpadding=2 cellspacing=1
bordercolor="#799AE1" class=tableBorder>
<tbody>
<tr>
<th align=center colspan=16 >商品顯示</th>
</tr>
<tr align="center" bgcolor="#799AE1" >
<td width="10%" align="center" class=txlHeaderBackgroundAlternate>商品編號(hào)</td>
<td width="10%" align="center" class=txlHeaderBackgroundAlternate>商品大類(lèi)</td>
<td width="10%" align="center" class=txlHeaderBackgroundAlternate>商品名稱(chēng)</td>
<td width="10%" align="center" class=txlHeaderBackgroundAlternate>商品規(guī)格</td>
<td width="10%" align="center" class=txlHeaderBackgroundAlternate>加權(quán)進(jìn)價(jià)</td>
<td width="10%" align="center" class=txlHeaderBackgroundAlternate>當(dāng)前售價(jià)</td>
<td width="10%" align="center" class=txlHeaderBackgroundAlternate>操作</td>
</tr>
<c:forEach items="${goodsS}" var="goods">
<tr bgcolor="#DEE5FA">
<td align="center" id="goodsId" class="txlrow"><c:out
value="${goods.goodsId}"></c:out></td>
<td align=center id="goodsType" class=txlrow><c:out
value="${goods.goodsType}"></c:out></td>
<td align=center id="goodsName" class=txlrow><c:out
value="${goods.goodsName}"></c:out></td>
<td align=center id="goodsContent" class=txlrow><c:out
value="${goods.goodsContent}"></c:out></td>
<td align=center id="goodsPrice" class=txlrow><c:out
value="${goods.goodsPrice}"></c:out></td>
<td align=center id="goodsSell" class=txlrow><c:out
value="${goods.goodsSell}"></c:out></td>
<td align=center class=txlrow> <input type="button" value="編輯"></td>
</tr>
</c:forEach>
</tbody>
</table>
<!--分頁(yè)顯示-->
<div id="Pagination"></div>js
var limit=<%=request.getAttribute("limit")%>;//每頁(yè)顯示多少 條數(shù)據(jù)
var count=<%=request.getAttribute("count")%>//共多少條數(shù)據(jù)
var index=<%=request.getAttribute("index")%>;//當(dāng)前記錄數(shù)
$(function(){
$("#Pagination").pagination(count, {
items_per_page:limit, // 每頁(yè)顯示多少條記錄
current_page: Math.ceil(index/limit), //當(dāng)前頁(yè)
num_display_entries:4, // 分頁(yè)顯示的條目數(shù)
next_text:"下一頁(yè)",
prev_text:"上一頁(yè)",
num_edge_entries:2, // 連接分頁(yè)主體,顯示的條目數(shù)
callback:handlePaginationClick
});
});
function handlePaginationClick(new_page_index, pagination_container) {
var path="<%=ppath%>/goodsManager/searchGoodsBylimit/" + new_page_index*limit;
$("#goodsForm").attr("action",path );
$("#goodsForm").submit();
return false;
}控制器
@RequestMapping(value = "/searchGoodsBylimit/{index}")
public String searchGoodsBylimitPst(Model model,
@ModelAttribute Goods goods, @PathVariable String index,
HttpServletRequest request) {
//索引
if (index == null || index.equals("")) {
index = "0";
//從服務(wù)器獲取數(shù)據(jù)
List<Goods> goodsS = goodsService.selectGoods(goods,
Integer.parseInt(index), PageParam.limit);
if (goodsS != null) {
model.addAttribute("goodsS", goodsS);
} else {
model.addAttribute("resultMsg", "沒(méi)有該商品");
}
//數(shù)據(jù)總條數(shù)
int count = goodsService.selectAllCount(goods);
model.addAttribute("index", index);
model.addAttribute("count", count);
model.addAttribute("limit", PageParam.limit);
System.out.println("第" + index + "數(shù)據(jù)開(kāi)始顯示" + goodsS.size() + "條記錄");
return "goodsManager/showGoods";
}效果圖

關(guān)于怎么在jquery中使用pagination.js實(shí)現(xiàn)分頁(yè)問(wèn)題的解答就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,如果你還有很多疑惑沒(méi)有解開(kāi),可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關(guān)知識(shí)。
本文題目:怎么在jquery中使用pagination.js實(shí)現(xiàn)分頁(yè)-創(chuàng)新互聯(lián)
當(dāng)前鏈接:http://www.chinadenli.net/article8/dcdpop.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供移動(dòng)網(wǎng)站建設(shè)、靜態(tài)網(wǎng)站、虛擬主機(jī)、網(wǎng)站營(yíng)銷(xiāo)、網(wǎng)站制作、網(wǎng)站設(shè)計(jì)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容