【問題】:表格重載時沒有清除原來的where參數(shù)场晶,在網(wǎng)上搜索各種方法都沒有效果,自己嘗試各種方法,發(fā)現(xiàn)目前該方法有效怕敬。
【解決辦法】
- 創(chuàng)建表格對象
layui.use('table', function () {
var table = layui.table;
tableObj = table.render({
id: "tableId",
url: 'url', //數(shù)據(jù)接口
elem: '#tableId',
page: {
limit: 15,
limits: [15, 30, 50, 100]
}, //開啟分頁
cols: [[ //表頭
...
]],
where: $("#formId").serializeJson()
});
});
2.重新渲染表格
//當修改查詢條件時,重新渲染表格
layui.use('table', function () {
var table = layui.table;
//tableObj為創(chuàng)建表格的對象
tableObj.config.where = $("#formId").serializeJson();
table.render(tableObj.config);
});