Extjs 4 树面板重新加载和展开
我正在使用带有 Json 数据的 Extjs4 树面板。我想重新加载树面板并需要将树菜单展开到指定节点。 我正在使用以下代码。请让我知道如何做到这一点。
//Define tree store
var store = Ext.create('Ext.data.TreeStore', {
proxy: {
type: 'ajax',
url: 'my_tree.php',
},
noCache: false
});
// Treepanel
var treePanel = Ext.create('Ext.tree.Panel', {
id: 'mytree',
renderTo: 'tree_div',
height: 400,
bodyBorder: false,
border: false,
singleExpand: true,
rootVisible: false,
store: store,
useArrows: true
});
//Reload tree
function reload_tree(){
var tree_panel = Ext.getCmp('mytree');
tree_panel.enable();
tree_panel.getLoader().dataUrl = 'my_tree.php';
tree_panel.getLoader().load(tree_panel.root);
//Expand tree node
tree_panel.getLoader().on('load', function(loader, node){
tree_panel.getNodeById(nodeid).expand();
//here node id is tree menu nodeid
});
}
提前致谢
I'm using Extjs4 treepanel with Json data.I want reload the treepanel and need expand tree menu to specified node.
I'm using the following code. Please let me know how do this.
//Define tree store
var store = Ext.create('Ext.data.TreeStore', {
proxy: {
type: 'ajax',
url: 'my_tree.php',
},
noCache: false
});
// Treepanel
var treePanel = Ext.create('Ext.tree.Panel', {
id: 'mytree',
renderTo: 'tree_div',
height: 400,
bodyBorder: false,
border: false,
singleExpand: true,
rootVisible: false,
store: store,
useArrows: true
});
//Reload tree
function reload_tree(){
var tree_panel = Ext.getCmp('mytree');
tree_panel.enable();
tree_panel.getLoader().dataUrl = 'my_tree.php';
tree_panel.getLoader().load(tree_panel.root);
//Expand tree node
tree_panel.getLoader().on('load', function(loader, node){
tree_panel.getNodeById(nodeid).expand();
//here node id is tree menu nodeid
});
}
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
重新加载树,我认为调用它更简单
,然后您可以监听加载事件,以便获取所有数据,最后从那里选择所需的节点。
哈!
Reload the tree i think it's simpler to just call
then you can listen to the load event, so that the data is all fetched and finally from there select the desired node.
HTH!