问题描述
我使用 tree.Panel 和 TreeStore 组件.我使用 JSON 文件来存储我的数据,但我想知道,如何使用 TreeStore 升级我的数据?!
I use tree.Panel and TreeStore component. I use JSON file to store my datas but i would like know, how to upgrade my data with a TreeStore ?!
我解释我的问题:我的页面上有 2 个组件:
I explain my problem : I have 2 components on my page :
Tree.Panel 用 TreeStore 和 Panel 显示数据来编辑数据,因为我没有找到如何直接编辑树?!
Tree.Panel who display data with TreeStore and Panel to editing data, because i don't find how to editing tree directly ?!
我想使用提交按钮来更新我的树上的数据,但我不明白该怎么做?!
I want to use a Submit button to update data on my tree but i don't understand how to do this?!
如果可能?!
我不明白如何添加新节点、升级节点和删除节点?!
I don't understand how i can add new node , upgrade node and delete node ?!
或者可能存在 TreeEditor 组件?!
Or there exist maybe TreeEditor component ?!
非常感谢帮助:)
推荐答案
我想我们还没有看到 TreeEditor 组件.但是有一些方法可以操作您现有的树.您应该能够使用 节点接口.
I think we are yet to see a TreeEditor component. But there are ways to manipulate your existing tree. You should be able to add, update, remove tree nodes using the methods of NodeInterface.
你有这样的方法:
- appendChild
- insertChild
- 插入之前
- removeChild
- replaceChild
等等...
这是一个示例代码,如何将新节点附加到树中:
Here is a sample code how you can append a new node to your tree:
var node = myTreeStore.getRootNode();
node.appendChild({
text: 'A New node'
});
同样,您可以使用其他方法来操作树.要将节点插入到特定位置,您必须使用 insertChild
.对于此方法,您还必须指定位置.
Similarly you can make use of other methods to manipulate the tree. To insert node into specific location, you will have to use the insertChild
. For this method, you will have to specify the location as well.
简而言之,编辑树的访问点是 TreeStore 的 getRootNode()
方法.
In short, the access point of editing your tree is your TreeStore's getRootNode()
method.
这篇关于如何使用 TreeStore 或 TreeEditor 组件更新数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!