亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

layui實現(xiàn)數(shù)據(jù)分頁功能

 更新時間:2019年07月27日 11:58:58   作者:阿杜_ardo  
這篇文章主要為大家詳細介紹了layui實現(xiàn)數(shù)據(jù)分頁功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了layui實現(xiàn)數(shù)據(jù)分頁功能,供大家參考,具體內(nèi)容如下

官網(wǎng)layui table演示頁面

示例截圖:

頁面引入layui.css、 layui.js

<div id="pTable" style="width: 1200px;">
  <table class="layui-table" id="layui_table_id" lay-filter="test">
  </table>
<div id="laypage"></div>
 </div>

前臺js

var limitcount = 10;
 var curnum = 1;
 //列表查詢方法
 function productsearch(productGroupId,start,limitsize) {
  layui.use(['table','laypage','laydate'], function(){
   var table = layui.table,
    laydate=layui.laydate,
    laypage = layui.laypage;
   table.render({
    elem: '#layui_table_id'
    , url: '<%=path%>/xx/pListQuery.html?pId='+productGroupId+'¤tPage='+ start+'¤tNumber=' + limitsize
    /*, where:{pagename:start,pagelimit:limitsize} //傳參*/
    , cols: [[
     {field: 'productId', title: 'ID', width: '170', sort: true}
     , {field: 'productName', title: '名稱', width: '450'}
     , {field: 'productState', title: '狀態(tài)', width: '100'}
     , {field: 'effectTime', title: '生效時間', width: '120', sort: true}
     , {field: 'invalidTime', title: '失效時間', width: '120', sort: true}
     , {field: 'productCost', title: '成本', width: '100', sort: true}
     , {field: 'poperation', title: '操作', width: '100',fixed: 'right', toolbar: '#barDemo'}
    ]]
    , page: false
    , height: 430
    ,done: function(res, curr, count){
     //如果是異步請求數(shù)據(jù)方式,res即為你接口返回的信息。
     //如果是直接賦值的方式,res即為:{data: [], count: 99} data為當前頁數(shù)據(jù)、count為數(shù)據(jù)總長度
     laypage.render({
      elem:'laypage'
      ,count:count
      ,curr:curnum
      ,limit:limitcount
      ,layout: ['prev', 'page', 'next', 'skip','count','limit']
      ,jump:function (obj,first) {
       if(!first){
        curnum = obj.curr;
        limitcount = obj.limit;
        //console.log("curnum"+curnum);
        //console.log("limitcount"+limitcount);
        //layer.msg(curnum+"-"+limitcount);
        productsearch(productGroupId,curnum,limitcount);
       }
      }
     })
    }
   })
 
   //監(jiān)聽工具條
   table.on('tool(test)', function(obj){ //注:tool是工具條事件名,test是table原始容器的屬性 lay-filter="對應(yīng)的值"
    var data = obj.data //獲得當前行數(shù)據(jù)
     ,layEvent = obj.event; //獲得 lay-event 對應(yīng)的值
    if(layEvent === 'detail'){
     viewLableInfo(data.attrId);
     layer.msg(data.attrId);
    } else if(layEvent === 'del'){
     layer.msg('刪除');
    } else if(layEvent === 'edit'){
     layer.msg('編輯操作');
    }
   });
   //常規(guī)用法
   laydate.render({
    elem: '#createDate'
   });
   //常規(guī)用法
   laydate.render({
    elem: '#processingTime'
   });
 
  });
 }
  var pId = '${pGBean.pgId }';
productsearch(pId, curnum, limitcount);

業(yè)務(wù)邏輯層

@Override
  public String queryList (HttpServletRequest request) {
   String total = "";
   String pId = request.getParameter("pId");
   int currentNumber = Integer.parseInt(request.getParameter("currentNumber"));
  String currentPage = request.getParameter("currentPage") == null ? "1" : request.getParameter("currentPage");
  //分頁處理,顯示第一頁的30條數(shù)據(jù)(默認值)
  PageHelper.startPage(Integer.parseInt(currentPage), currentNumber);
  List<PExl> list = exportDao.queryList (pId);
  if(list.size() > 0){
   total = list.get(0).getTotal();
  }
  
  Page page = PageHelper.localPage.get();
  if(page!=null){
   page.setCurrentPage(Integer.parseInt(currentPage));
  }
  PageHelper.endPage();
 
  JSONObject jsonObject = new JSONObject();
  jsonObject.put("code", 0);
  jsonObject.put("msg", "");
  jsonObject.put("count", total);
  jsonObject.put("data", list);
  //System.out.println("json:----" + jsonObject.toString());
  return jsonObject.toString();
  }

sql

其中sql在計算總數(shù)totle時可以這么寫

COUNT(*) OVER(PARTITION BY 1) AS TOTAL

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 微信小程序 自定義消息提示框

    微信小程序 自定義消息提示框

    這篇文章主要介紹了微信小程序 自定義消息提示框的相關(guān)資料,wx.showToast(OBJECT)接口調(diào)用,實現(xiàn)改功能,需要的朋友可以參考下
    2017-08-08
  • JS仿淘寶實現(xiàn)的簡單滑動門效果代碼

    JS仿淘寶實現(xiàn)的簡單滑動門效果代碼

    這篇文章主要介紹了JS仿淘寶實現(xiàn)的簡單滑動門效果,可實現(xiàn)按字母分類滑動切換的功能,非常簡單實用,需要的朋友可以參考下
    2015-10-10
  • Javascript異步編程的4種方法讓你寫出更出色的程序

    Javascript異步編程的4種方法讓你寫出更出色的程序

    本文總結(jié)了"異步模式"編程的4種方法,理解它們可以讓你寫出結(jié)構(gòu)更合理、性能更出色、維護更方便的Javascript程序
    2013-01-01
  • 跟我學(xué)習(xí)JScript的Bug與內(nèi)存管理

    跟我學(xué)習(xí)JScript的Bug與內(nèi)存管理

    跟我學(xué)習(xí)JScript的Bug與內(nèi)存管理,小編對JScript的Bug與內(nèi)存管理也不甚了解,所以整理了本篇文章,希望可以解決大家學(xué)習(xí)時的困擾。
    2015-11-11
  • 關(guān)于JS前端實現(xiàn)水印的代碼操作

    關(guān)于JS前端實現(xiàn)水印的代碼操作

    這篇文章主要介紹了關(guān)于JS前端實現(xiàn)水印的代碼操作,文中給出了詳細的實現(xiàn)思路和代碼示例供大家參考,對大家的學(xué)習(xí)或工作有一定的幫助,需要的朋友可以參考下
    2024-06-06
  • BootStrap柵格之間留空隙的解決方法

    BootStrap柵格之間留空隙的解決方法

    BootStrap柵格系統(tǒng)可以把我們的container容器劃分為若干等分,如果想要每個部分之間留出一定的空隙,那么應(yīng)該怎么解決,本文就來介紹一下
    2021-08-08
  • javascript分頁代碼(當前頁碼居中)

    javascript分頁代碼(當前頁碼居中)

    昨天看了妙味課堂的 分頁視頻教程,今天自己參照其思路,自己寫了下,并且自己新增了一個顯示頁碼個數(shù)的屬性 showPageNum
    2012-09-09
  • js實現(xiàn)簡單的手風琴效果

    js實現(xiàn)簡單的手風琴效果

    本文主要介紹了js實現(xiàn)簡單手風琴效果的實例,具有很好的參考價值,下面跟著小編一起來看下吧
    2017-02-02
  • js 實現(xiàn)的可折疊留言板(附源碼下載)

    js 實現(xiàn)的可折疊留言板(附源碼下載)

    留言板想必大家都有見過吧,但是可以折疊的卻不是很多,恰好本文提供一個比較不錯的可折疊留言板,感興趣的朋友可以學(xué)習(xí)下
    2014-07-07
  • D3.js實現(xiàn)折線圖的方法詳解

    D3.js實現(xiàn)折線圖的方法詳解

    眾所周知圖表是數(shù)據(jù)圖形化的表示,通過形象的圖表來展示數(shù)據(jù),比如條形圖,折線圖,餅圖等等??梢暬瘓D表可以幫助開發(fā)者更容易理解復(fù)雜的數(shù)據(jù),提高生產(chǎn)的效率和 Web 應(yīng)用和項目的可靠性?,F(xiàn)在就讓我們大家一起來學(xué)習(xí)用D3.js來實現(xiàn)折線圖。
    2016-09-09

最新評論