你不能像大多数例子一样使用树店吗?如果你这样做了,树会自动从 store 中请求节点,并且 store 会从服务器加载东西。鉴于您的服务器代码可以在给定特定节点的情况下发回分支。
请参阅 Sencha Kitchen Sink 演示,该演示使用 TreeStore 对服务器进行操作。
如果您在 Chrome 中打开开发人员工具,转到网络选项卡,然后在树中展开一个节点,您将看到 TreeStore 将通过从给定 id 的“get-nodes.php”请求数据来自动加载该节点的子节点展开的节点。
您可以通过简单地调用.expand()
它来扩展节点。
如果这不起作用,你可以只加载模型,当你拥有它时,将它添加到树中并像这样展开父级:
MyApp.model.MyTreeModel.load(someId, {
success: function (record, operation) {
// If the third param is true the search will be recursive from the supplied node
var node = tree.getRootNode().findChild('id', someParentId, true);
node.addChild(record);
node.expand();
},
scope: this
});
你的问题有点宽泛,所以我希望这对你有所帮助。
您可能想查看有关如何操作树的 Ext.data.NodeInterface 文档。