1
0
mirror of https://gitee.com/layui/layui.git synced 2025-04-05 17:38:02 +08:00

优化 table 内部选中值的相关想法

This commit is contained in:
贤心 2023-05-30 09:52:51 +08:00
parent 82e0740423
commit d8789d68d5

View File

@ -1576,10 +1576,10 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
}
};
//请求loading
// 请求 loading
Class.prototype.loading = function(hide){
var that = this
,options = that.config;
var that = this;
var options = that.config;
if(options.loading){
if(hide){
that.layInit && that.layInit.remove();
@ -1594,14 +1594,22 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
}
};
//同步选中值状态
Class.prototype.setCheckData = function(index, checked){
var that = this
,options = that.config
,thisData = table.cache[that.key];
// 同步选中值状态
Class.prototype.setCheckData = function(index, checked, radio){
var that = this;
var options = that.config;
var thisData = table.cache[that.key];
if(!thisData[index]) return;
if(layui.type(thisData[index]) === 'array') return;
thisData[index][options.checkName] = checked;
layui.each(thisData, function(i, item){
if(index === i){
item[options.checkName] = checked;
} else if(radio) { // 是否单选
delete item[options.checkName];
}
});
};
// 同步全选按钮状态