//初始化表格 function initTable() { var baseConfig = { uniqueId: "MemberID" //指定主鍵列 , sortName: "CreateDate" //默認排序列 , sortOrder: "desc" , method: "post" , queryParams: that._methods.tableParams , pagination: true //顯示分頁 , sidePagination: 'server' //設置在哪里進行分頁,可選值為 'client' 或者 'server'。設置 'server'時,必須設置 服務器數據地址(url)或者重寫ajax方法 , pageNumber: 1 , pageSize: 20 , pageList: [20, 30, 50] //設置為 All 或者 Unlimited,則顯示所有記錄。 , columns: [ //配置顯示列 { checkbox: false, width: 1 } , { field: "MemberName", title: "客戶", width: 160, sortable: true } , { field: "Status", title: "狀態", width: 100, sortable: true, formatter: function (val, row, index) { if (val) return val === 1 ? "啟用" : "禁用"; else return val = "未配置"; } } , { field: "CreateUser", title: "創建人", width: 100, sortable: true } , { field: "CreateDate", title: "創建時間", width: 140, sortable: true, formatter: function (val, row, index) { return val == null ? "" : _fn.ToDate(val).format('yyyy-MM-dd hh:mm:ss'); } } , { field: "", title: "操作", width: 100, sortable: false, formatter: function (val, row, index) { var config_div = "<div class='shelf_edit'><a onclick='_methods.ConfigModalShow(" + row.MemberID + ")' title='配置'>配置</a>"; if (row.Status == 1) return config_div += " <a onclick='_methods.SwitchEnableStatus(" + row.MemberID + "," + row.Status + ")' title='禁用'>禁用</a></div>"; else return config_div += " <a onclick='_methods.SwitchEnableStatus(" + row.MemberID + "," + row.Status + ")' title='啟用'>啟用</a></div>"; } } ] , onLoadSuccess: function (data) { } , search: false , singleSelect: true }; var tabConfig = _fn.GetTabDefaultConfig(baseConfig); that._doms.table.bootstrapTable(tabConfig); }
更多知識分享網址:http://www.itxst.com/