首先,需要获取表格的ID
1、表格工具栏的操作按钮获取,按钮位于表格的左上角或者右上角
table.on('toolbar(itemFieldSrcTable1)', function(obj){
var id = obj.config.id;
var layEvent = obj.event;
active[layEvent].call(this,{tableIns:tableIns1,row:{name:''}});
});
2、表格的操作列:
table.on('tool(itemFieldSrcTable3)', function (obj) {
var layEvent = obj.event;
let tableId = obj.config.id
active[layEvent].call(this,{tableIns:tableIns3,data:obj.data,obj:obj});
});
3、从表格的实例对象获取
let config = tableObj.config;
let tableId = config.id;
4、在table 的done回调里获取:
done: function(res, curr, count){
var options = this;
let tableId = options.id;//对应当前表格的ID
}
获取列表的缓存数据:
getTableCacheData:function (tableId){
return table.cache[tableId]||[];
}
获取某一行的数据:
getRowData:function (tableId, elem){
var index = $(elem).closest('tr').data('index');
return table.cache[tableId][index] || {};
}
标签:obj,layui,缓存数据,tableId,var,table,config,id
From: https://blog.51cto.com/u_14816966/9279194