bootstrap table表格插件使用詳解
bootstrp-table學習,具體內(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: '編號', sortable: true, halign: 'center'}, {field: 'username', title: '賬號', 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: '手機', 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ù)處理和回顯,當然,bootstrap-table的使用需要前后臺協(xié)調(diào)進行。
在使用bootstrap-table過程中需要注意:
接口返回數(shù)據(jù)格式[json]包含的兩個字段: total(數(shù)據(jù)總計)與rows(數(shù)據(jù)),即{"total":24,"rows":[...]}
分頁包括服務(wù)器端和客戶端兩種情況,務(wù)器端分頁的參數(shù)默認值為limit,offset,search,sort,order Else,通過queryParamsType參數(shù)可對其進行重寫
columns字段中:file 表示返回字段的屬性名;title表示th標題內(nèi)容;formatter表示自定義列表顯示內(nèi)容,包含三個參數(shù),value, row, index,對應(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(''); }
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
在WordPress中加入Google搜索功能的簡單步驟講解
這篇文章主要介紹了在WordPress中加入Google搜索的簡單步驟講解,谷歌搜索很有用,但同時也要注意在國內(nèi)使用cse的連通性,需要的朋友可以參考下2016-01-01微信小程序?qū)崿F(xiàn)列表滾動頭部吸頂?shù)氖纠a
這篇文章主要介紹了微信小程序?qū)崿F(xiàn)列表滾動頭部吸頂?shù)氖纠a,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-07-07