-
19 May 2008 12:57 PM #1
Reload tree panel
Reload tree panel
Hello:
I have a tree panel that loads data from the server and I have a form too. With this form the user can to change data on the server and i need to reload the treepanel when the user submit the form, wich is in a php archive.
This is the code for the tree panel:
And this is the code associated to the save form button:PHP Code:var myTree = new Tree.TreePanel('tree-div', {
loader: new Tree.TreeLoader({dataUrl:'./PHP/tree_generator.php'}),
containerScroll: true,
id:'arbol',
animate:true,
enableDrag:true,
dropConfig: {appendOnly:true},
rootVisible:true
});
var root = new Tree.AsyncTreeNode({
text: 'Facultad 5',
id:'facultad',
draggable:false
});
myTree.setRootNode(root);
myTree.render();
myTree.expandAll();
[php]form.addButton("Guardar", function(){
form.submit({
params: {action:'submit'},
waitTitle:'Espere por favor',
waitMsg: 'Enviando los datos...',
success: function(form, action){
Ext.Msg.show({
title:'Confirmaci
-
26 May 2008 6:36 AM #2
A variant
A variant
Hello again, my english is so bat, sorry for this.
I have a possible solution here to the previous problem, but doesn't work totally fine.
So, I have a toolbar and in a button click event, I call this function:
So, the data is loaded perfectly but the child icons never appear and a folder icon shows in it's stead. I need to know, that it's wrong? I finaly load refresh the nodes and now they doesn't show the correct icon.PHP Code:function refrescar_datos_pp(){
myTree.getLoader().load(myTree.root);
myTree.root.render();
myTree.expandAll();
}
function expandAll(){
setTimeout(function(){
Rroot.eachChild(function(n){
n.expand(false, false);
});
}, 10);
};

Any help is welcome.
Thanks in advance.
-
26 May 2008 7:34 AM #3
Try setting leaf: false, expanded: true for all your nodes (then they should all render expanded)
-
30 May 2008 6:07 AM #4
-
4 Jul 2011 1:21 PM #5
Please! Tell me! How to reload tree panel in ExtJS 4? I have a form, when I submit form I wanna refresh my tree. Help please!
-
17 Oct 2011 7:02 AM #6
-
17 Oct 2011 11:25 PM #7
Variant №1 - from view or Viewport(doesn't matter)
tr.getView().getTreeStore().setRootNode(tr.getView().getTreeStore().getRootNode().getChildAt());
tr.getView().refresh();
tr - it's your view with TreePanel
Variant №2 - from Controller
reloadTree:function(){
Ext.getStore('Comments').setRootNode(Ext.getStore('Comments').getRootNode().getChildAt());
or
this.getCommentsStore().setRootNode(getCommentsStore().getRootNode().getChildAt());
this.getCommentsStore().load();
}
The main point is that you should reload root node.
Please let me know if it works
-
18 Oct 2011 2:42 AM #8
thank you soo much
i didnt expect an answer and definitely not so soon
thank you
i tried ur code, it does reload the tree but it gives me an empty tree (im not using mvc)
this is what i used
myStore.setRootNode(myStore.getRootNode().getChildAt());
myStore is the name of my store, i can access it directly
i need to fill it but i dont know how!
this is the definition of my store
Code:window.myStore = Ext.create('Ext.data.TreeStore', { root: Ext.decode(obj.TreeToJson()) });


Reply With Quote