欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

bootstrap table表格客戶端分頁實(shí)例

 更新時間:2017年08月07日 08:43:13   作者:alan_liuyue  
這篇文章主要為大家詳細(xì)介紹了bootstrap table表格客戶端分頁實(shí)例,具有一定的參考價值,感興趣的小伙伴們可以參考一下

一、前言

    bootstrap-table是非常方便好用的前端表格分頁插件,使用者只需要提供數(shù)據(jù)源就能實(shí)現(xiàn)非常完美的分頁效果,其分頁方式可以分成客戶端分頁和服務(wù)端分頁,其接收的數(shù)據(jù)源都是json數(shù)據(jù)格式。服務(wù)端分頁在項目中應(yīng)用得非常的廣泛,但有時也需要使用客戶端分頁來加快分頁速度,加快分頁瀏覽效率。本篇博客就不介紹服務(wù)端分頁,只提供bootstrap-table客戶端分頁的簡單例子(數(shù)據(jù)源也從前端獲?。?,供初學(xué)者了解使用。

二、實(shí)例

<title>bootstrap-table表格客戶端分頁</title> 
 
 <link rel="stylesheet" href="./bootstrap/css/bootstrap/bootstrap.css" rel="external nofollow" /> 
 <link rel="stylesheet" href="./bootstrap-table/bootstrap-table.css" rel="external nofollow" />  
  
 <script src="./jquery/jquery.min.js"></script> 
 <script src="./bootstrap/js/bootstrap.js"></script> 
 <script src="./bootstrap-table/bootstrap-table.js"></script> 
 <script src="./bootstrap-table/bootstrap-table-export.js"></script> 
 <script src="./extends/tableExport/jquery.base64.js"></script> 
 <script src="./extends/tableExport/tableExport.js"></script> 
 
</head> 
 
<body > 
 <div id="reportTableDiv" > 
  <table id="reportTable"></table> 
 </div> 
 <script type="text/javascript"> 
 //手動制造30條數(shù)據(jù) 
 var datas = []; 
 for(var i=0;i<30;i++){ 
  datas[i]={"name":"傻逼"+i+"號","age":"年齡:"+i+"歲","sex":"男"+i} 
 } 
  
 $(function () { 
  $('#reportTable').bootstrapTable({ 
   method: 'get', 
   cache: false, 
   height: 400, 
   striped: true, 
   pagination: true, 
   pageSize: 20, 
   pageNumber:1, 
   pageList: [10, 20, 50, 100, 200, 500], 
   search: true, 
   showColumns: true, 
   showRefresh: false, 
   showExport: false, 
   exportTypes: ['csv','txt','xml'], 
   search: true, 
   clickToSelect: true, 
   columns: 
   [ 
    {field:"checked",checkbox:true}, 
    {field:"name",title:"測試姓名",align:"center",valign:"middle",sortable:"true"}, 
    {field:"age",title:"年齡",align:"center",valign:"middle",sortable:"true"}, 
    {field:"sex",title:"性別",align:"center",valign:"middle",sortable:"true"}, 
   ], 
   data:datas, 
  });          
 }); 
 </script> 
<div> 
  
</body> 
</html> 

三、總結(jié)

    1. bootstrap-table客戶端分頁只需要幾個步驟即可實(shí)現(xiàn):引入bootstrap的js、css;html頁面添加一個table標(biāo)簽同時給id賦值;js添加初始化代碼;

    2.bootstrap-table客戶端分頁的數(shù)據(jù)源可以是服務(wù)器端傳遞過來,也可以是前端js獲取,該實(shí)例使用的是前端js的數(shù)據(jù)源,初始化參數(shù)需要添加data,同時去掉url;

   3.本博客的實(shí)例下載路徑

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

相關(guān)文章

最新評論