修复 treeTable 执行 `treeTable.addNodes()` 增加节点导致当前节点选中状态丢失的问题

pull/1315/head
贤心 1 year ago
parent bd67afa744
commit 8f2fb6e5e3

@ -1265,6 +1265,7 @@ layui.define(['table'], function (exports) {
var options = that.getOptions(); var options = that.getOptions();
var treeOptions = options.tree; var treeOptions = options.tree;
var tableViewElem = options.elem.next(); var tableViewElem = options.elem.next();
var checkName = table.config.checkName;
opts = opts || {}; opts = opts || {};
@ -1280,6 +1281,13 @@ layui.define(['table'], function (exports) {
// 添加数据 // 添加数据
newNodes = $.extend(true, [], (layui.isArray(newNodes) ? newNodes : [newNodes])); newNodes = $.extend(true, [], (layui.isArray(newNodes) ? newNodes : [newNodes]));
// 若未传入 LAY_CHECKED 属性,则继承父节点的 checked 状态
layui.each(newNodes, function(i, item){
if(!(checkName in item)){
item[checkName] = parentNode[checkName];
}
})
var tableData = that.getTableData(), dataAfter; var tableData = that.getTableData(), dataAfter;
if (!parentNode) { if (!parentNode) {
// 添加到根节点 // 添加到根节点

Loading…
Cancel
Save