Layui get a table id
-
The first step: table attribute table to have a lay-filter
<table class="app-table layui-table" id="reportTable" lay-filter="reportTable" lay-data="{id: 'reportTable'}"></table>
-
Step two: By acquiring table.checkStatus, corresponding to lay-filter properties, as follows:
// 任意button的按钮事件,比如新增
function add() {
var table = layui.table;
var checkStatus = table.checkStatus('reportTable');
var ids="";
for(var i=0; i<checkStatus.data.length; i++){
ids += checkStatus.data[i].id;
if(i !=checkStatus.data.length-1){
ids += ",";
}
}
console.log(ids)
}