mirror of https://github.com/layui/layui
优化 table 内部选中值的相关想法
parent
82e0740423
commit
d8789d68d5
|
@ -1578,8 +1578,8 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
|||
|
||||
// 请求 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();
|
||||
|
@ -1595,13 +1595,21 @@ 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];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 同步全选按钮状态
|
||||
|
|
Loading…
Reference in New Issue