Skip to content
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

[t-enhanced-table] 树形表格,不设置 :expandedTreeNodes.sync="expandedTreeNodes" 时,设置 data 数据变化后,展开节点依然是上一波数据的节点,导致新的数据节点展开有误 #2735

Open
RomenMark opened this issue Aug 25, 2023 · 11 comments

Comments

@RomenMark
Copy link

tdesign-vue 版本

1.6.3

重现链接

No response

重现步骤

1.用$refs.table.resetData设置数据 不用data(作为prop)保定表格数据
2.调用expendAll()函数出现表格数据消失问题

期望结果

No response

实际结果

No response

框架版本

vue(2.6.12)

浏览器版本

Chrome(112.0.5615.138)

系统版本

No response

Node版本

14.17.0

补充说明

No response

@github-actions
Copy link
Contributor

👋 @RomenMark,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

@chaishi
Copy link
Collaborator

chaishi commented Aug 25, 2023

没有 data 作为 props,初始数据从哪里来呢

@RomenMark
Copy link
Author

接口获取到数据 调用 $refs.table.resetData()

没有 data 作为 props,初始数据从哪里来呢

@RomenMark
Copy link
Author

没有 data 作为 props,初始数据从哪里来呢

之前生产环境是正常的,最近更新了包的版本才出现的问题

@chaishi
Copy link
Collaborator

chaishi commented Aug 25, 2023

用法属于规划之外的用法,如果希望尽快处理,就给 props.data 赋值。

由于是非官方推荐用法,且 issue 信息缺少 “重现链接”,请在下方链接中复现你的问题
https://stackblitz.com/edit/cvcsdp?file=package.json,src%2Fdemo.vue
问题复现后,保存代码,会生成新的链接,然后贴到 issue 中。(当前 issue 仅提供了的两段文字描述,过于简洁,难以处理)

@RomenMark
Copy link
Author

https://stackblitz.com/edit/scsnsd?file=src%2Fdata.js,src%2Fdemo.vue

1.引入数据a 和 b 层级不一样 节点数量不一样的两个树形结构

2.表格先赋值数量多的b数据 并且点击全部展开

3.点击切换数据 切换到数量少的 a (模拟的是异步获取数据 重新赋值data)

4.展开显示不符合正常情况

@RomenMark
Copy link
Author

1692957943312
1692957958825

@RomenMark
Copy link
Author

上诉错误在重新收起展开后 显示正常。是否应该在绑定的data变化后,自动重置收缩状态

@chaishi chaishi added the invalid This doesn't seem right label Aug 27, 2023
@chaishi
Copy link
Collaborator

chaishi commented Aug 27, 2023

https://stackblitz.com/edit/scsnsd-1mvslm?file=src%2Fdata.js,src%2Fdemo.vue
当前,根据链接里面这样写,可以解决你的问题。

<t-enhanced-table :expandedTreeNodes.sync="expandedTreeNodes" />

切换数据

methods: {
  onChangeData() {
      this.data = a;
      // [] 表示不展开节点;数组里面可以添加你希望展开的任意节点
      this.expandedTreeNodes = [];
   },
}

@chaishi chaishi changed the title [t-enhanced-table] 树形表格expandAll方法存在bug [t-enhanced-table] 树形表格,不设置 :expandedTreeNodes.sync="expandedTreeNodes" 时,数据变化后展开节点状态有误 Aug 27, 2023
@chaishi chaishi changed the title [t-enhanced-table] 树形表格,不设置 :expandedTreeNodes.sync="expandedTreeNodes" 时,数据变化后展开节点状态有误 [t-enhanced-table] 树形表格,不设置 :expandedTreeNodes.sync="expandedTreeNodes" 时,设置 data 数据变化后,展开节点依然是上一波数据的节点,导致新的数据节点展开有误 Aug 27, 2023
@chaishi chaishi removed the invalid This doesn't seem right label Aug 27, 2023
@chaishi
Copy link
Collaborator

chaishi commented Aug 27, 2023

expandedTreeNodes.sync 存在时,组件内部无需处理,所有展开节点均可由 expandedTreeNodes.sync控制。

对于 expandedTreeNodes.sync 不存在场景,数据变化时,重置收起所有已展开的节点,处理细节如下,
Vue2 resolved in #2742
Vue3 resolved in Tencent/tdesign-vue-next#3283
React resolved in Tencent/tdesign-react#2470

@chaishi chaishi added the to be published fixed, not be published label Aug 27, 2023
@xiaosansiji
Copy link
Collaborator

fixed in 1.6.4

@chaishi chaishi removed the to be published fixed, not be published label Sep 4, 2023
@uyarn uyarn reopened this Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants