BootStrap中Table分頁(yè)插件使用詳解
分頁(yè)(Pagination),是一種無(wú)序列表,Bootstrap 像處理其他界面元素一樣處理分頁(yè)。
bootstrap-table介紹
bootstrap-table 是一個(gè)輕量級(jí)的table插件,使用AJAX獲取JSON格式的數(shù)據(jù),其分頁(yè)和數(shù)據(jù)填充很方便,支持國(guó)際化。
下載地址
https://github.com/wenzhixin/bootstrap-table/archive/1.11.0.zip
使用方式
引入css和js
<!--css樣式--> <link href="css/bootstrap/bootstrap.min.css" rel="stylesheet"> <link href="css/bootstrap/bootstrap-table.css" rel="stylesheet"> <!--js--> <script src="js/bootstrap/jquery-1.12.0.min.js" type="text/javascript"></script> <script src="js/bootstrap/bootstrap.min.js"></script> <script src="js/bootstrap/bootstrap-table.js"></script> <script src="js/bootstrap/bootstrap-table-zh-CN.js"></script>
2. table數(shù)據(jù)填充
bootstrap-table獲取數(shù)據(jù)有兩種方式,一是通過(guò)table 的data-url屬性指定數(shù)據(jù)源,二是通過(guò)JavaScript初始化表格時(shí)指定url來(lái)獲取數(shù)據(jù)
<table id="screenTable" data-toggle="table">
<thead>
...
</thead>
</table>
$(function () {
$('#screenTable').bootstrapTable({
url: "/screen/list",
dataField: "rows",
cache: false, //是否使用緩存,默認(rèn)為true
striped: true, //是否顯示行間隔色
pagination: true, //是否顯示分頁(yè)
pageSize: 10, //每頁(yè)的記錄行數(shù)
pageNumber: 1, //初始化加載第一頁(yè),默認(rèn)第一頁(yè)
pageList: [10, 20, 50], //可供選擇的每頁(yè)的行數(shù)
search: true, //是否顯示表格搜索
showRefresh: true, //是否顯示刷新按鈕
clickToSelect: true, //是否啟用點(diǎn)擊選中行
toolbar: "#toolbar_screen", //工具按鈕用哪個(gè)容器
sidePagination: "server", //分頁(yè)方式:client客戶端分頁(yè),server服務(wù)端分頁(yè)
queryParamsType: "limit", //查詢參數(shù)組織方式
columns: [{
field: "id",
title: "ID",
align: "center",
valign: "middle"
}, {
field: "name",
title: "定制名稱",
align: "center",
valign: "middle",
formatter: 'infoFormatter'
}, {
field: "time",
title: "定制時(shí)間",
align: "center",
valign: "middle"
}],
formatNoMatches: function () {
return '無(wú)符合條件的記錄';
}
});
$(window).resize(function () {
$('#screenTable').bootstrapTable('resetView');
});
});
function infoFormatter(value, row, index) {
return '<a href=/screen/' + row.id + ' target="_blank">' + row.name + '</a>';
}
效果圖如下

以上所述是小編給大家介紹的BootStrap中Table分頁(yè)插件使用詳解,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
- bootstrap table表格插件之服務(wù)器端分頁(yè)實(shí)例代碼
- bootstrap table 服務(wù)器端分頁(yè)例子分享
- bootstrap-table后端分頁(yè)功能完整實(shí)例
- Bootstrap table分頁(yè)問(wèn)題匯總
- 第一次動(dòng)手實(shí)現(xiàn)bootstrap table分頁(yè)效果
- bootstrap table插件的分頁(yè)與checkbox使用詳解
- BootStrap Table前臺(tái)和后臺(tái)分頁(yè)對(duì)JSON格式的要求
- bootstrap table分頁(yè)模板和獲取表中的ID方法
- 使用bootstraptable插件實(shí)現(xiàn)表格記錄的查詢、分頁(yè)、排序操作
- bootstrap-table實(shí)現(xiàn)服務(wù)器分頁(yè)的示例 (spring 后臺(tái))
- BootStrap Table后臺(tái)分頁(yè)時(shí)前臺(tái)刪除最后一頁(yè)所有數(shù)據(jù)refresh刷新后無(wú)數(shù)據(jù)問(wèn)題
- Bootstrap table 服務(wù)器端分頁(yè)功能實(shí)現(xiàn)方法示例
相關(guān)文章
微信小程序?qū)崿F(xiàn)天氣預(yù)報(bào)功能(附源碼)
這篇文章主要介紹了微信小程序?qū)崿F(xiàn)天氣預(yù)報(bào)功能(附源碼),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-12-12
echarts報(bào)錯(cuò):Error?in?mounted?hook的解決方法
最近又遇到了寫(xiě)echarts的時(shí)候常遇到的一個(gè)錯(cuò)誤,這篇文章主要給大家介紹了關(guān)于echarts報(bào)錯(cuò):Error?in?mounted?hook:?“TypeError:?Cannot?read?properties?of?undefined?(reading?‘init‘)“的解決方法,需要的朋友可以參考下2022-07-07
layui 監(jiān)聽(tīng)select選擇 獲取當(dāng)前select的ID名稱方法
今天小編就為大家分享一篇layui 監(jiān)聽(tīng)select選擇 獲取當(dāng)前select的ID名稱方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-09-09
layui實(shí)現(xiàn)checkbox的目錄樹(shù)tree的例子
今天小編就為大家分享一篇layui實(shí)現(xiàn)checkbox的目錄樹(shù)tree的例子,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-09-09

