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
n-tree 初始化设置default-checked-keys后,不会触发@update:checked-keys和@update:indeterminate-keys #3837
Comments
一个场景是:后台只给了6个全选的数据,这样给到ne-tree的时候, 会有半选的节点被勾选上,现在可能6个全选 + 2个半选的节点,此时我保存数据给后台的话, 按照现有的逻辑就拿不到另外两个半选节点的数据 |
@07akioni 这在现在的系统中很重要, 希望可以考虑满足这种场景。不然设置过全选数据后,不勾选一下复选框 就无法触发@update:checked-keys和@update:indeterminate-keys回调,,无法再拿到相关的半选数据。 |
官方的组件都是受控和非受控, 所以 default- 的应该都是非受控的, 如果需要使用受控 checked 的话,直接使用 checked-keys 就可以, 而且 on-update:checked-keys 很明显和 checked-keys 是一对, indeterminate-keys 也有对应的 onUpdate |
如果数据全是全选数据,使用checked-keys, 此时会有对应被勾选的半选数据,但如果不触发回调,是拿不到对应被勾选的半选数据, |
|
同时需要 |
场景是:你初始化默认给checked-keys赋值(里面是全选的数据), 此时不进行任何操作,应该是拿不到对应半选的数据吧 ? |
只有勾选了,触发了(on-update:indeterminate-keys) 回调,才可以拿到, 如果初始化之后,不进行勾选操作,但此时Tree中已经有了关联的半选数据,就拿不到了。 |
这个确实 |
所以之前也有issue提到有种场景是这样的,初始化给全选数据, 但是现在Tree对应的也有半选, 然后我什么也不勾选,我现在提交给后台,想把半选的一起给, 就没有办法能解决 |
这些方法会考虑尽快加上,我理解确实用户需要 |
至于不触发显然是个正确的行为,解决方式还得是加方法 |
@07akioni 非常感谢,初始化不触发是可以的,希望能尽快提供些方法,目前导致整个系统的Tree无法正常回显和二次编辑, 感谢 |
@07akioni 类似问题,mark!!!设置了checed-keys之后,整个树的checkbox无法点击。 |
it will be added in the next version |
TuSimple/naive-ui version (版本)
2.33.4
Vue version (Vue 版本)
3.2.40
Browser and its version (浏览器及其版本)
chrome
System and its version (系统及其版本)
windows
Node version (Node 版本)
Reappearance link (重现链接)
https://codesandbox.io/s/r0c7vg?file=/src/Demo.vue
Reappearance steps (重现步骤)
n-tree 初始化设置default-checked-keys后,不会触发@update:checked-keys和@update:indeterminate-keys
Expected results (期望的结果)
当我初始化default-checked-keys的时候, 如果不手动点击一下复选框,不会触发@update:checked-keys和@update:indeterminate-keys,则无法拿到indeterminate半选的数据
是否可以像elementplus一样提供
getHalfCheckedKeys
getCheckedKeys
等方法来解决这个场景
Actual results (实际的结果)
n-tree 初始化设置default-checked-keys后,不会触发@update:checked-keys和@update:indeterminate-keys
Remarks (补充说明)
The text was updated successfully, but these errors were encountered: