Browse Source

修复 treeTable 组件 treeTable.setRowChecked 未逐层展开上级节点的问题 (#1385)

* 修复 treeTable 组件 treeTable.setRowChecked 未逐层展开上级节点的问题

修复 treeTable 组件 treeTable.setRowChecked 未逐层展开上级节点的问题

* Update treeTable.js
pull/1391/head
morning-star 1 year ago committed by GitHub
parent
commit
ca574d1c11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 24
      src/modules/treeTable.js

24
src/modules/treeTable.js

@ -1791,14 +1791,30 @@ layui.define(['table'], function (exports) {
// 目前只能处理当前页的数据
return;
}
var collectNeedExpandNodeIndex = function(index){
needExpandIndex.push(index);
var trElem = tableView.find('tr[lay-data-index="' + index + '"]');
if (!trElem.length) {
var nodeData = that.getNodeDataByIndex(index);
var parentIndex = nodeData[LAY_PARENT_INDEX];
parentIndex && collectNeedExpandNodeIndex(parentIndex);
}
}
// 判断是否展开过
var trElem = tableView.find('tr[lay-data-index="' + dataIndex + '"]');
if (!trElem.length) {
var parentIndex = nodeData[LAY_PARENT_INDEX];
var needExpandIndex = [];
collectNeedExpandNodeIndex(parentIndex);
// 如果还没有展开没有渲染的要先渲染出来
treeTable.expandNode(id, {
index: nodeData[LAY_PARENT_INDEX],
expandFlag: true
});
layui.each(needExpandIndex.reverse(),function(index, nodeIndex){
treeTable.expandNode(id, {
index: nodeIndex,
expandFlag: true
});
})
trElem = tableView.find('tr[lay-data-index="' + dataIndex + '"]');
}
checkNode.call(that, trElem, checked, callbackFlag);

Loading…
Cancel
Save