You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Request to optimize the treeData update mechanism of the Tree component, add a method for updating the title, and add a method for adding and deleting nodes
#5555
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.
function AddNode(parentkey:string,nodeData:any){
//增加一个子节点
}
function DeleteNode(parentkey:string,nodeData:any){
//移除一个子节点
}
The text was updated successfully, but these errors were encountered:
github-actionsbot
changed the title
请求对Tree组件treeData更新机制优化,添加更新title的方法,添加增加和删除节点的方法
Request to optimize the treeData update mechanism of the Tree component, add a method for updating the title, and add a method for adding and deleting nodes
Apr 27, 2022
Hello @liupan1890. We totally like your proposal/feedback, welcome to send us a Pull Request for it. Please send your Pull Request to proper branch, fill the Pull Request Template here, provide changelog/TypeScript/documentation/test cases if needed and make sure CI passed, we will review it soon. We appreciate your effort in advance and looking forward to your contribution!
What problem does this feature solve?
当前Tree组件绑定的treeData数据格式为:
当执行绑定时,vctree会把treeData的children层级撸平,转换为这样(仅表达逻辑,不要抠细节):
当前,每一次有数据需要更新的时候
情景一:新增/删除 数据; (比如增加一个
{ title: '一行新的数据', key: '0-0-new', }
)情景二:修改某一条数据的title; (比如修改
{ title: 'parent 1', key: '0-0', }
变成{ title: '新的名字', key: '0-0', }
)--
这时都需要执行代码
treeData = treeData.concat()
触发Tree的完整刷新,才能正确显示关键 的是,会导致vctree 重新转换一遍数据
修改一行数据,看看都干了啥:
1.复制一遍10W条数据(treeData.concat())
2.vctree 遍历10W条数据,重新转换成一个新数组(创建一个10W条的新数组),并匹配每一条节点的parent节点
3.刷新整个Tree的dom(几十条数据*每条数据十几个HTMLElement [icon,line,checkbox,title...])
这个操作是没必要的,也是十分浪费性能的
我们预期的是,修改一行数据时
只修改这个节点的title,只刷新这个节点对应呈现的那十几个HTMLElement [icon,line,checkbox,title...]
没有复制10W(treeData.concat())
没有转换10W(vctree)
没有整个Tree刷新
情景三:修改某一条数据的CheckBox选中状态;(比如点击一行勾选)
这个操作也会触发整个Tree刷新,但幸运的是不会导致vctree 重新转换10W的数组
--
所以希望提供一个公开的API方法,调用此方法,直接修改对应key的节点数据,并判断此节点是否在showData(虚拟树正在显示的节点列表)中,需要的话刷新一下此节点对应的dom
What does the proposed API look like?
The text was updated successfully, but these errors were encountered: