怎么在jquery中使用pagination.js實(shí)現(xiàn)分頁

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

為海滄等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計(jì)制作服務(wù),及海滄網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為做網(wǎng)站、成都網(wǎng)站設(shè)計(jì)、海滄網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎ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)簽,獲取控制器傳過來的值

<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>商品大類</td>
     <td width="10%" align="center" class=txlHeaderBackgroundAlternate>商品名稱</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>

<!--分頁顯示-->
<div id="Pagination"></div>

js

var limit=<%=request.getAttribute("limit")%>;//每頁顯示多少 條數(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, // 每頁顯示多少條記錄
  current_page: Math.ceil(index/limit), //當(dāng)前頁
  num_display_entries:4, // 分頁顯示的條目數(shù)
  next_text:"下一頁",
  prev_text:"上一頁",
  num_edge_entries:2, // 連接分頁主體,顯示的條目數(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", "沒有該商品");
  }
  //數(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ù)開始顯示" + goodsS.size() + "條記錄");
  return "goodsManager/showGoods";
 }

效果圖

怎么在jquery中使用pagination.js實(shí)現(xiàn)分頁

關(guān)于怎么在jquery中使用pagination.js實(shí)現(xiàn)分頁問題的解答就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關(guān)知識(shí)。

名稱欄目:怎么在jquery中使用pagination.js實(shí)現(xiàn)分頁
網(wǎng)站URL:http://muchs.cn/article30/ihsopo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供靜態(tài)網(wǎng)站、營(yíng)銷型網(wǎng)站建設(shè)、響應(yīng)式網(wǎng)站、Google、移動(dòng)網(wǎng)站建設(shè)、云服務(wù)器

廣告

聲明:本網(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í)需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站建設(shè)