bootstrap table表格插件使用詳解
bootstrp-table學(xué)習(xí),具體內(nèi)容如下
$table.bootstrapTable({
url: '../data/data1.json',
striped: true,
minimumCountColumns: 2,
clickToSelect: true,
detailView: true,
detailFormatter: 'detailFormatter',
pagination: true,
paginationLoop: false,
classes: 'table table-hover table-no-bordered',
sidePagination: 'server',
silentSort: false,
queryParamsType:'',
queryParams: queryParams : function(params) {
var subcompany = $('#subcompany option:selected').val();
var name = $('#name').val();
return {
pageNumber: params.offset+1,
pageSize: params.limit,
companyId:subcompany,
name:name
};
},
smartDisplay: false,
idField: 'id',
sortable: false,
escape: true,
idField: 'systemId',
maintainSelected: true,
toolbar: '#toolbar',
columns: [
{field: 'state', checkbox: true},
{field: 'id', title: '編號(hào)', sortable: true, halign: 'center'},
{field: 'username', title: '賬號(hào)', sortable: true, halign: 'center'},
{field: 'password', title: '密碼', sortable: true, halign: 'center'},
{field: 'name', title: '姓名', sortable: true, halign: 'center'},
{field: 'sex', title: '性別', sortable: true, halign: 'center'},
{field: 'age', title: '年齡', sortable: true, halign: 'center'},
{field: 'phone', title: '手機(jī)', sortable: true, halign: 'center'},
{field: 'email', title: '郵箱', sortable: true, halign: 'center'},
{field: 'address', title: '地址', sortable: true, halign: 'center'},
{field: 'remark', title: '備注', sortable: true, halign: 'center'},
{field: 'action', title: '操作', halign: 'center', align: 'center', formatter: 'actionFormatter', events: 'actionEvents', clickToSelect: false}
]
}).on('all.bs.table', function (e, name, args) {
$('[data-toggle="tooltip"]').tooltip();
$('[data-toggle="popover"]').popover();
});
bootstrap-table是一種表格插件,可用作后管系統(tǒng)的數(shù)據(jù)處理和回顯,當(dāng)然,bootstrap-table的使用需要前后臺(tái)協(xié)調(diào)進(jìn)行。
在使用bootstrap-table過(guò)程中需要注意:
接口返回?cái)?shù)據(jù)格式[json]包含的兩個(gè)字段: total(數(shù)據(jù)總計(jì))與rows(數(shù)據(jù)),即{"total":24,"rows":[...]}
分頁(yè)包括服務(wù)器端和客戶端兩種情況,務(wù)器端分頁(yè)的參數(shù)默認(rèn)值為limit,offset,search,sort,order Else,通過(guò)queryParamsType參數(shù)可對(duì)其進(jìn)行重寫
columns字段中:file 表示返回字段的屬性名;title表示th標(biāo)題內(nèi)容;formatter表示自定義列表顯示內(nèi)容,包含三個(gè)參數(shù),value, row, index,對(duì)應(yīng) 為file值,行數(shù)據(jù),行數(shù)
function actionFormatter(value, row, index) {
return [
'<a class="like" href="detail.html" rel="external nofollow" data-toggle="tooltip" title="詳情"><i class="glyphicon glyphicon-pencil"></i></a> ',
'<a class="edit ml10" href="javascript:createAction()" rel="external nofollow" data-toggle="tooltip" title="修改密碼"><i class="glyphicon glyphicon-edit"></i></a> ',
].join('');
}
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
在WordPress中加入Google搜索功能的簡(jiǎn)單步驟講解
這篇文章主要介紹了在WordPress中加入Google搜索的簡(jiǎn)單步驟講解,谷歌搜索很有用,但同時(shí)也要注意在國(guó)內(nèi)使用cse的連通性,需要的朋友可以參考下2016-01-01
layui 阻止圖片上傳的實(shí)例(before方法)
今天小編就為大家分享一篇layui 阻止圖片上傳的實(shí)例(before方法),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-09-09
詳解Chart.js輕量級(jí)圖表庫(kù)的使用經(jīng)驗(yàn)
這篇文章主要介紹了詳解Chart.js輕量級(jí)圖表庫(kù)的使用經(jīng)驗(yàn),Chart.js很容易上手,只需要在頁(yè)面中引用腳本文件,并創(chuàng)建 <canvas> 節(jié)點(diǎn)即可渲染出圖表,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-05-05
微信小程序?qū)崿F(xiàn)列表滾動(dòng)頭部吸頂?shù)氖纠a
這篇文章主要介紹了微信小程序?qū)崿F(xiàn)列表滾動(dòng)頭部吸頂?shù)氖纠a,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-07-07

