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過程中需要注意:
接口返回?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,通過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í)有所幫助,也希望大家多多支持武林網(wǎng)。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注