PDA

View Full Version : How to refresh the tree panel view in ExtJs3.4 ?



venkatesh teja
10 Mar 2014, 10:25 PM
Hi...

How to refresh the tree panel view in ExtJs3.4

Can any one help me...?

slemmon
13 Mar 2014, 10:28 AM
There's not really a public refresh method for the tree. When are you finding you're needing to do a manual refresh?

cgi-bin
21 Mar 2014, 12:18 PM
Here's how I did it...

First, extend the TreePanel class and add a reloadTree function:

customTreePanel = Ext.extend
(
Ext.tree.TreePanel
,{
activePath:null
,initEvents:function()
{
customTreePanel.superclass.initEvents.call(this);
}
,reloadTree:function()
{
this.getLoader().load(this.getRootNode());
}
}
);

I use my tree as kind of a navigation menu... your usage my differ, but here's how I configured mine:

navPanel = new customTreePanel
({
id:'nav-tree'
,header:true
,title:'Navigation'
,tools:
[{
id:'refresh'
,handler:function(e, t, p, c)
{
p.reloadTree();
}
,qtip:'Refresh Navigation List'
}]
,singleExpand:true
,width:200
,lines:false
,autoScroll:true
,loader:new Ext.tree.TreeLoader
({
baseAttrs:
{
allowDrag:false
,allowDrop:false
,editable:false
,singleClickExpand:true
}
,dataUrl:'/foo/bar'
,preloadChildren:true
,listeners:
{
loadexception:function(t, n, r)
{
alert('TreeLoader: an exception occurred');
}
}
})
,rootVisible:false
,root:new Ext.tree.AsyncTreeNode
({
allowDrag:false
,allowDrop:false
,editable:false
,id:'root'
,expanded:true
})
});

I have some more customization done to the navPanel/tree for my layout, which I never figured out how to get working in ExtJS 4, so I've been stuck in 3.x land :">