Layui get a table id

Layui get a table id

  1. 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>
    
  2. 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)
    }

Here Insert Picture Description

Guess you like

Origin blog.csdn.net/a5252145/article/details/94740626