laytable一次性獲取數據後,點擊刪除調用後臺刪除。返回成功狀態後刷新當前頁數據。css
渲染方法:ajax
//渲染表格 function renderingTable(pageIndex, sourceData, count, msg) { var obj = { elem: '#table_data', data: sourceData, cols: [[ { field: 'SITE_DATABASE_ID', title: 'SITE_DATABASE_ID', hide: true, } , { field: 'DATA_NAME', title: '數據庫名稱' } , { field: 'TABLE_NAME', title: '表名', sort: true } , { field: 'TABLE_INFO', title: '表描述', sort: true } , { field: 'IS_VERTICAL_TABLE', title: '是否豎表', sort: true, templet: function (res) { if (res.IS_VERTICAL_TABLE == 1) { return "是"; } else { return "否"; } } } , { field: 'VERTICAL_TABLE_KEY_COLUMNAME', title: '豎表主鍵1', sort: true } , { field: 'VERTICAL_TABLE_KEY2_COLUMNAME', title: '豎表主鍵2', sort: true } , { field: 'TIME_COLUMN_NAME', title: '數據時間列', sort: true } , { field: 'TIME_IS_REPEAT', title: '時間列值是否重複', sort: true, templet: function (res) { if (res.TIME_IS_REPEAT == 1) { return "是"; } else { return "否"; } } } , { field: 'SELECFT_CONDITION', title: '查詢Sql條件', sort: true } , { field: 'IS_CLIENT_GET', title: '客戶端採集狀態', sort: true, templet: function (res) { if (res.IS_CLIENT_GET == 1) { return "採集"; } else { return "不採集"; } } } , { field: 'CREATE_TIME', title: '建立時間', sort: true } , { fixed: 'right', title: '操做', align: 'center', toolbar: '#operation' } ]], count: count, height: $(".partial-content").height() - parseInt($(".page-content").css("padding-top")) - parseInt($(".page-content").css("padding-bottom")) - $(".div_select").height() - 90, page: { curr: pageIndex, limit: 15, limits: [15, 50, 100], }, totalRow: false, skin: 'line ', even: false, loading: true, parseData: function (res) { return { "msg": msg , "count": count }; } }; tableData = laytable.render(obj); };
刪除代碼:數據庫
//刪除 function deleteData(baseId) { layer.confirm('肯定刪除嗎?', { btn: ['肯定', '取消'] }, function () { var parm = { baseId: baseId } $.majax({ type: "Post", url: "/ClientGetTableConfig/DeleteData", data: parm, dataType: "json", success: function (data) { var datas = JSON.parse(data); if (datas.Success == 1) { $.layermsg_s('刪除成功', 1); tableData.config.data = tableData.config.data.filter((item) => item.SITE_DATABASE_ID != baseId); var pageSum = parseInt(tableData.config.data.length / tableData.config.limit); var pageIndex = tableData.config.page.curr; pageSum = tableData.config.data.length % tableData.config.limit > 0 ? pageSum + 1 : pageSum; pageIndex = pageIndex > pageSum ? pageSum : pageIndex; renderingTable(pageIndex, tableData.config.data, tableData.config.data.length, ""); } else { $.layermsg_e(datas.SuccessStr, 1); } } }); }); };
laytable.render渲染表格後返回的對象有你想要的一切湊字數laytable獲取當前頁,laytable獲取當前條數laytable獲取當前頁,laytable獲取當前條數laytable獲取當前頁,laytable獲取當前條數laytable獲取當前頁,laytable獲取當前條數laytable獲取當前頁,laytable獲取當前條數laytable獲取當前頁,laytable獲取當前條數laytable獲取當前頁,laytable獲取當前條數laytable獲取當前頁,laytable獲取當前條數laytable獲取當前頁,laytable獲取當前條數laytable獲取當前頁,laytable獲取當前條數laytable獲取當前頁,laytable獲取當前條數laytable獲取當前頁,laytable獲取當前條數laytable獲取當前頁,laytable獲取當前條數