-
Notifications
You must be signed in to change notification settings - Fork 358
feat: add batch expand/collapse all tree nodes #4033
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add batch expand/collapse all tree nodes #4033
Conversation
packages/vtable/src/ListTable.ts
Outdated
|
||
// 刷新视图 | ||
if (stateChanged) { | ||
this.updateColumns(this.internalProps.columns); // 应用表头变化并重新评估列 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的逻辑有点奇怪 可以看看有没有其他更好的逻辑
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是的,感谢指出!updateColumns 应该是一个开销比较大的操作,这里会造成性能的浪费,是一个可以优化的点
@fangsmile 我增加和使用了 |
看起来还是有问题,可以试一下这个示例
|
感谢耐心的测试!我注意到这是一段 PivotTable 透视表的配置。关于节点一次性展开/折叠全部节点的能力,目前只针对 ListTable 进行了处理。关于 PivotTable 透视表的处理,我还在进行相应的修改 |
@Rui-Sun 关于透视表节点的一键展开/折叠,也进行了相应的支持,请求再次审核 |
packages/vtable/src/PivotTable.ts
Outdated
col: -1, | ||
row: -1, | ||
hierarchyState: HierarchyState.collapse, | ||
originData: this.internalProps.layoutMap.columnDimensionTree.tree |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
触发事件的这个originData可以去掉。事件定义中加个明确的参数changeAll:boolean
packages/vtable/src/ListTable.ts
Outdated
expandAllTreeNode(): void { | ||
let stateChanged = false; | ||
|
||
// 展开所有表头节点 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
把这块逻辑先去掉吧 后续有需求可以单独开个header的接口
/** | ||
* 展开所有树形节点 | ||
*/ | ||
expandAllTreeNode(): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** | ||
* 展开行表头树的所有节点 | ||
*/ | ||
expandAllForRowTree() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个也一样先判断是否是tree模式 columnHierarchyType rowHierarchyType
/**层级维度结构显示形式 */
rowHierarchyType?: 'grid' | 'tree' | 'grid-tree';
columnHierarchyType?: 'grid' | 'grid-tree';
记得测试下 'tree' | 'grid-tree'
嗯嗯好的,已经完成了相应的修改,'tree' | 'grid-tree' 在 demo 上的测试也是 ok 的 |
8aa0002
into
VisActor:feat/add_batch_expand_collapse_api
[中文版模板 / Chinese template]
🤔 This is a ...
🔗 Related issue link
relate #3078
💡 Background and solution
实现方案:
增强底层数据层:在 DataSource 中增加了 expandAllNodes() 和 collapseAllNodes() 方法,通过递归遍历数据源,统一设置所有节点的 hierarchyState 属性,并重建表格的层级状态。
基于数据层增加 API :在 ListTable 中新增了两个公共 API:expandAllTreeNode() 和 collapseAllTreeNode()。这两个方法会同步更新表头和数据行的节点状态,然后刷新整个表格视图,并触发相应的 TREE_HIERARCHY_STATE_CHANGE 事件。
功能演示:
新增 API 及使用示例:
📝 Changelog
☑️ Self-Check before Merge
🚀 Summary
copilot:summary
🔍 Walkthrough
copilot:walkthrough