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

[Table] 如果在 validateTableData 中更改 data 数据,会校验历史Table Data数据 #3148

Closed
lin-code-world opened this issue Jul 25, 2023 · 9 comments
Assignees
Labels
need more info need more information to resolve issue to be published to be published

Comments

@lin-code-world
Copy link

tdesign-vue-next 版本

1.3.12

重现链接

https://stackblitz.com/edit/audbg8-pkh4ye?file=src%2Fmain.js,src%2Fvalidator.jsx

重现步骤

可编辑table,调用校验方法validateTableData之前,修改table的data值,调用validateTableData之后发现会同时校验历史的data数据。如果row-key设置一个随机值,调用校验方法validateTableData之前给table data重新赋值,每次调用校验方法之后发现会把之前的历史data都会校验。调用校验方法应该只校验当前的table data数据。
需求场景是,需要对列表数据进行修改,会变更table的data值然后提交的时候进行校验。

期望结果

调用校验方法应该只校验当前的table data数据。

实际结果

调用校验方法validateTableData会校验历史的table data数据。

框架版本

3.3.4

浏览器版本

No response

系统版本

No response

Node版本

No response

补充说明

No response

@github-actions
Copy link
Contributor

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

@github-actions
Copy link
Contributor

github-actions bot commented Jul 25, 2023

♥️ 有劳 @Louiszhai @PengYYYYY @chaishi 尽快确认问题。
确认有效后将下一步计划和可能需要的时间回复给 @lin-code-world

@chaishi
Copy link
Collaborator

chaishi commented Jul 25, 2023

可编辑表格,数据分 2 种:非编辑态数据 和 实时变化的编辑态数据。只有确定保存成功后,才会更新非编辑态的表格数据,如果取消(不保存),则不会更新表格数据。(编辑态数据字段,相当于一个小型的 Form 表单,有独立的数据状态)

故而,进入编辑态之后,编辑态会有单独的数据变量,此时的输入框数据变化,不会影响表格本身的 data 数据。

⚠️ data.value = [{ key: Date.now(), name: 'test' }]; 这段代码,更新的是 “非编辑态 的表格数据”。而 validateTableData 校验的是 “编辑态的表单数据”。

应该是需要提供一个更新编辑态表单数据的方法,类似这个 issue 的问题:Tencent/tdesign-vue#2577

image

@chaishi chaishi changed the title [Table] validateTableData会校验历史Table Data数据 [Table] 如果在 validateTableData 中更改 data 数据,会校验历史Table Data数据 Jul 25, 2023
@lin-code-world
Copy link
Author

可编辑表格,数据分 2 种:非编辑态数据 和 实时变化的编辑态数据。只有确定保存成功后,才会更新非编辑态的表格数据,如果取消(不保存),则不会更新表格数据。(编辑态数据字段,相当于一个小型的 Form 表单,有独立的数据状态)

故而,进入编辑态之后,编辑态会有单独的数据变量,此时的输入框数据变化,不会影响表格本身的 data 数据。

⚠️ data.value = [{ key: Date.now(), name: 'test' }]; 这段代码,更新的是 “非编辑态 的表格数据”。而 validateTableData 校验的是 “编辑态的表单数据”。

应该是需要提供一个更新编辑态表单数据的方法,类似这个 issue 的问题:Tencent/tdesign-vue#2577

image

我的需求是,第一次整个table处于全编辑状态,校验不通过,不保存,取消,之后table data赋值一个新数据,这时只想校验新数据,可是会把旧数据也校验了,如何满足需求?能否加一个清空/初始化“编辑态表单数据”的方法。

@chaishi
Copy link
Collaborator

chaishi commented Jul 27, 2023

@lin-code-world 你的需求场景,方便提供一个更完整 demo 吗

@uyarn uyarn added the need more info need more information to resolve issue label Aug 6, 2023
@lin-code-world
Copy link
Author

@lin-code-world 你的需求场景,方便提供一个更完整 demo 吗

@chaishi https://stackblitz.com/edit/audbg8-fgarxg?file=src%2Fvalidator.jsx,src%2Fmain.js
先新增一行空数据,点击校验,会对该行数据进行校验,显示校验不通过。然后删除该行数据,再次点击校验,按理说应该校验通过,实际还是会对旧数据进行校验,校验不通过。

@ZJQ0925
Copy link

ZJQ0925 commented Jan 3, 2024

请问下这个问题解决了吗 @lin-code-world

@lin-code-world
Copy link
Author

请问下这个问题解决了吗 @lin-code-world

没有,官方没人解决,现在更新到1.9.9,这个问题依然存在。校验逻辑只能自己实现,取出当前的表格集合自己判断,不用validateTableData方法

@uyarn
Copy link
Collaborator

uyarn commented Dec 31, 2024

fixed 1.10.6

@uyarn uyarn closed this as completed Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need more info need more information to resolve issue to be published to be published
Projects
None yet
Development

No branches or pull requests

5 participants