mirror of https://github.com/layui/layui
优化 table 内部选中值的相关想法
parent
82e0740423
commit
d8789d68d5
|
@ -1576,10 +1576,10 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//请求loading
|
// 请求 loading
|
||||||
Class.prototype.loading = function(hide){
|
Class.prototype.loading = function(hide){
|
||||||
var that = this
|
var that = this;
|
||||||
,options = that.config;
|
var options = that.config;
|
||||||
if(options.loading){
|
if(options.loading){
|
||||||
if(hide){
|
if(hide){
|
||||||
that.layInit && that.layInit.remove();
|
that.layInit && that.layInit.remove();
|
||||||
|
@ -1594,14 +1594,22 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//同步选中值状态
|
// 同步选中值状态
|
||||||
Class.prototype.setCheckData = function(index, checked){
|
Class.prototype.setCheckData = function(index, checked, radio){
|
||||||
var that = this
|
var that = this;
|
||||||
,options = that.config
|
var options = that.config;
|
||||||
,thisData = table.cache[that.key];
|
var thisData = table.cache[that.key];
|
||||||
|
|
||||||
if(!thisData[index]) return;
|
if(!thisData[index]) return;
|
||||||
if(layui.type(thisData[index]) === 'array') 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];
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 同步全选按钮状态
|
// 同步全选按钮状态
|
||||||
|
|
Loading…
Reference in New Issue