From 8f2fb6e5e365befd1b37b19907511183322eeeee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Tue, 8 Aug 2023 17:46:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20treeTable=20=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=20`treeTable.addNodes()`=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E5=AF=BC=E8=87=B4=E5=BD=93=E5=89=8D=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E9=80=89=E4=B8=AD=E7=8A=B6=E6=80=81=E4=B8=A2=E5=A4=B1?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/treeTable.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/modules/treeTable.js b/src/modules/treeTable.js index 08ee9102..dd033bd0 100644 --- a/src/modules/treeTable.js +++ b/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) { // 添加到根节点