Browse Source

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

pull/1315/head
贤心 1 year ago
parent
commit
8f2fb6e5e3
  1. 8
      src/modules/treeTable.js

8
src/modules/treeTable.js

@ -1265,6 +1265,7 @@ layui.define(['table'], function (exports) {
var options = that.getOptions();
var treeOptions = options.tree;
var tableViewElem = options.elem.next();
var checkName = table.config.checkName;
opts = opts || {};
@ -1280,6 +1281,13 @@ layui.define(['table'], function (exports) {
// 添加数据
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;
if (!parentNode) {
// 添加到根节点

Loading…
Cancel
Save