//自動化渲染的重載 HTML】 <table class="layui-table" lay-data="{id: 'idTest'}"> …… </table> 【JS】 table.reload('idTest', { url: '/api/table/search' ,where: {} //設定異步數據接口的額外參數 //,height: 300 });
//方法級渲染的重載 //所獲得的 tableIns 即為當前容器的實例 var tableIns = table.render({ elem: '#id' ,cols: [] //設置表頭 ,url: '/api/data' //設置異步接口 ,id: 'idTest' }); //這里以搜索為例 tableIns.reload({ where: { //設定異步數據接口的額外參數,任意設 aaaaaa: 'xxx' ,bbb: 'yyy' //… } ,page: { curr: 1 //重新從第 1 頁開始 } }); //上述方法等價於 table.reload('idTest', { where: { //設定異步數據接口的額外參數,任意設 aaaaaa: 'xxx' ,bbb: 'yyy' //… } ,page: { curr: 1 //重新從第 1 頁開始 } }); //只重載數據
語法 | 說明 | 適用場景 |
table.reload(ID, options) | 參數 ID 即為基礎參數id對應的值,見:設定容器唯一ID 參數 options 即為各項基礎參數 |
所有渲染方式 |
tableIns.reload(options) | 參數同上 tableIns 可通過 var tableIns = table.render() 得到 |
僅限方法級渲染 |