我的问题类似于http://www.sencha.com/forum/showthread.php?2916-insert-update-delete-child-nodes-dynamically
唯一不同的是我正在使用Ext.Tree。我将主页分为两部分。 我保留左侧部分用于在树形结构中显示数据,右侧部分用于显示屏幕中的一些细节。
目前有一些子节点在根节点(Source)下。当其中一个孩子点击时,我会在屏幕的右侧部分填充一些数据。
当我在网格的右侧部分添加或删除数据时,是否可以向我解释如何动态更新(插入/更新/删除)子节点。
Ext.onReady(function() {
var Tree = Ext.tree;
var tree = new Tree.TreePanel({
useArrows: true,
autoScroll: true,
animate: true,
enableDD: true,
containerScroll: true,
border: false,
// auto create TreeLoader
dataUrl:'[JS Array]',
root: {
nodeType: 'async',
text: 'ALL',
draggable: false,
id: ''
}
});
// render the tree
tree.render('tree-div');
tree.getRootNode().expand();
});
答案 0 :(得分:1)
您应该查看TreeNode课程。它有方法addChild()和getPath()以及removeChild,可用于从树中删除节点和叶子。
编辑:原始答案适用于已弃用的版本
当前文档链接: http://docs.sencha.com/extjs/6.2.1/classic/Ext.data.TreeStore.html#methods
当前的“经典”ext似乎统一了数据源,使用更接近传统数据存储的东西,这个传统的数据存储称为TreeStore,它允许你操纵树的树叶和树枝。