bootstrap table小案例
Bootstrap Table是基于Bootstrap的輕量級(jí)表格插件,只需要簡(jiǎn)單的配置就可以實(shí)現(xiàn)強(qiáng)大的支持固定表頭、單復(fù)選、排序、分頁(yè)、搜索以及自定義表頭等功能。
1、所需要的庫(kù):
bootstrap.min.css
bootstrap-table.css
jquery.min.js
bootstrap.min.js
bootstrap-table.js
2、Bootstrap Table獲取數(shù)據(jù)的方式:
Bootstrap Table通過(guò)data屬性標(biāo)簽或者JavaScript來(lái)顯示表格數(shù)據(jù):
(1)、通過(guò)data屬性標(biāo)簽
在表格中設(shè)置data-toggle=“table”,此方式可以在不寫JavaScript的情況下啟用Bootstrap Table。
<table data-toggle="table" data-url="data.json">
<thead>
...
</thead>
</table>
(2)、通過(guò)JavaScipt向表格傳入數(shù)據(jù):
<table id="table"></table>
<1>、簡(jiǎn)單的靜態(tài)數(shù)據(jù)
$('#table').bootstrapTable({
columns: [{
field: 'id',
title: 'Item ID'
}, {
field: 'username',
title: 'Item Username'
}, {
field: 'password',
title: 'Item Passowrd'
}],
data: [{
id: 1,
username: 'Item 1',
passowrd: '$1'
}, {
id: 2,
username: 'Item 2',
password: '$2'
}]});
<2>、通過(guò)url獲取數(shù)據(jù)
$('#table').bootstrapTable({
url: 'data1.json',
columns: [{
field: 'id',
title: 'Item ID'
}, {
field: 'username',
title: 'Item Username'
}, {
field: 'passowrd',
title: 'Item Passowrd'
}, ]});
3、Bootstrap Table簡(jiǎn)單的demo:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Bootstrap Table的demo</title>
<link rel="stylesheet" href="bootstrap.css">
<link rel="stylesheet" href="bootstrap-table.css">
</head>
<body>
<table id="table"></table>
<!--引入相關(guān)的js文件-->
<script src="jquery.min.js"></script>
<script src="bootstrap.js"></script>
<script src="bootstrap-table.js"></script>
<!--自定義javaScript-->
<script>
$('#table').bootstrapTable({
columns: [{
field: 'id',
title: 'Item ID'
}, {
field: 'username',
title: 'Item Username'
}, {
field: 'passsword',
title: 'Item Password'
}],
data: [{
id: 1,
username: 'Item 1',
passowrd: '123'
}, {
id: 2,
username: 'Item 2',
passowrd: '123
}]
});
</script>
</body>
</html>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
如果大家還想深入學(xué)習(xí),可以點(diǎn)擊這里進(jìn)行學(xué)習(xí),再為大家附兩個(gè)精彩的專題:Bootstrap學(xué)習(xí)教程 Bootstrap實(shí)戰(zhàn)教程
- JS表格組件神器bootstrap table詳解(基礎(chǔ)版)
- bootstrap table 服務(wù)器端分頁(yè)例子分享
- JS組件Bootstrap Table使用方法詳解
- Bootstrap Table使用方法詳解
- JS組件Bootstrap Table表格行拖拽效果實(shí)現(xiàn)代碼
- JS組件Bootstrap Table表格多行拖拽效果實(shí)現(xiàn)代碼
- Bootstrap嵌入jqGrid,使你的table牛逼起來(lái)
- Bootstrap table分頁(yè)問(wèn)題匯總
- 值得分享的輕量級(jí)Bootstrap Table表格插件
- JS組件Bootstrap Table布局詳解
相關(guān)文章
小程序中canvas的drawImage方法參數(shù)使用詳解
這篇文章主要介紹了小程序中canvas的drawImage方法參數(shù)使用詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-07-07
驚云JS隨機(jī)排序程序隨機(jī)顯示信息-每次新聞顯示順序都不一樣
驚云JS隨機(jī)排序程序隨機(jī)顯示信息-每次新聞顯示順序都不一樣...2007-11-11
JavaScript中的Error錯(cuò)誤對(duì)象與自定義錯(cuò)誤類型詳解
Error是JavaScript中最原始的錯(cuò)誤對(duì)象,作為各種異常的基礎(chǔ)對(duì)象,還有多個(gè)衍生的具體的錯(cuò)誤類型,這些錯(cuò)誤對(duì)象類型在nodejs中也可應(yīng)用,這篇文章主要介紹了JavaScript中的Error錯(cuò)誤對(duì)象與自定義錯(cuò)誤類型,需要的朋友可以參考下2022-12-12
js實(shí)用技巧之去除數(shù)組或者對(duì)象里重復(fù)選項(xiàng)
這篇文章主要給大家介紹了關(guān)于js實(shí)用技巧之去除數(shù)組或者對(duì)象里重復(fù)選項(xiàng)的相關(guān)資料,JavaScript數(shù)組有很多內(nèi)置方法,可以操作和處理數(shù)據(jù),文中通過(guò)代碼示例介紹的非常詳細(xì),需要的朋友可以參考下2023-08-08

