-
27 Jun 2008 7:54 AM #1
how to reload a treepanel by defferent parameter?
how to reload a treepanel by defferent parameter?
I have a treepanel,which at the top of it place a combobox toolbar.
when combobox selected send a selectedvalue .
like this:
my question is how to write the function myTreeCreat( selectvalue),Code:comboboxtree.on("select",function(){ var selectvalue=this.getValue(); myTreeCreat(selectvalue); });
assumed I use getRootNode(selectvalue) get the tree root node.
like this:
myRootNode=gerRootNode(selectvalue);
thus I have pass the parameter "selectvalue" to get the tree root node.
but I want to know how to pass a " defferent root" to the treepanel and reload it.
I have searched all forums,and get nothing on this.
any one help me?
-
27 Jun 2008 8:42 PM #2
-
27 Jun 2008 9:39 PM #3
I do not think I have a clear understanding about your all your problem but I will try to help you on the tree problem.
If you want to load a different set of tree nodes, first you can get the root node using the TreePanel.getRootNode() and replace its child with different set of nodes by calling TreeNode.removeChild() and TreeNode.appendChild() or you can just create a new TreePanel altogether.
-
28 Jun 2008 6:57 AM #4
I think I follow you here as I am having the same problem figuring this out.
Using the code from the ext tree example:
This works great, I get a tree with everything in the "music" directory.Code:var Tree = Ext.tree; var tree = new Tree.TreePanel({ el:'tree-div', x:50, ddGroup : 'center', useArrows:true, collapsible: true, shadow: true, autoScroll:true, animate:true, enableDD:true, containerScroll: true, loader: new Tree.TreeLoader({ dataUrl:'get-nodes.php' }) }); // set the root node var root = new Tree.AsyncTreeNode({ text: 'music', draggable:false, id:'music' }); tree.setRootNode(root); // render the tree tree.render(); root.expand();
Now as a simple example, I want a button that switches to another directory under my root called "movies". I've tried many different ways but I can't get a handle on the original tree object to change the root node and reload it.
I'm sure there is a simple answer, but I'm stuck.Code:var buttonHandler = function(button,event) { var newRoot = new Tree.AsyncTreeNode({ text: 'movies', draggable:false, id:'movies' }); tree.setRootNode(newRoot); tree.render(); //doesn't work tree.getRootNode().reload(); //doesn't work tree.getLoader().load(newRoot); //doesn't work };
Thanks in advance for any assistance.
-Ross
edit: Not trying to hijack the thread with my example. I just think woog and I are both missing the same thing conceptually about how the TreePanel can be reset/updated so I wanted to add some more context to the question.Last edited by rossbates; 28 Jun 2008 at 7:12 AM. Reason: addition
-
28 Jun 2008 10:52 AM #5
thanks franciscallo! I have tried your method. it does't work.
anything else I have tried some method like this:
I 'm sure that I have got the correct different RootNodes of the tree.Code:ui.remove(); //does't work. unregisterNode(currentRoot); //does't work. removeChild(); //does't work.
and it display correct at the first time of this tree load.
I use the AsyncTreeNode() to get the different treeRootNodes by different urls.
but the parameter pass to AsyncTreeNode() at the second time ,it point me:
it seems Ext has no driver to process this problem.Code:AsyncTreeNode()(undefined), or "A is undefined[Break on this error] Ext.tree.TreeEventModel=function(A){this...enable:function(){this.disabled=false}};" or"R is undefined[Break on this error] Ext.DomHelper=function(){var L=null;var ... N=A(O);return new Ext.Template(N)}}}();"
the rootnode of treepanel is unvariable.
any one can give me a help?Last edited by woog; 28 Jun 2008 at 8:55 PM. Reason: update
-
28 Jun 2008 6:24 PM #6
I think usability wise, it is not good to change the content of the tree but since I do not know how your whole app work, I will leave that up to you.
Woog: If you could post your code that would me help you a lot better.
Rossbates: Why dont you just show in the tree your music and movies folder and let them expand which folder they like?
If you still would like to change the content of your whole tree, you can just get the loader, point that dataUrl to somewhere else and/or update the base params, and reload the tree.
http://extjs.com/deploy/dev/docs/?cl...ree.TreeLoader
-
29 Jun 2008 6:58 AM #7
The reason I would want the tree root to change is if the user wanted to quickly navigate a non-contiguous section of the filesystem. For example the "file open" dialog in XP, or the favorites panel in KDE's Dolphin. The left hand panel allows you to jump from Desktop, to home, to music, etc..... the right hand panel is always relative. When navigating you think of the right panel as "everything below what I just selected on the left".
That being said, I really don't want to change the URL of the TreeLoader I just want to pass a different id for the root of my AsyncTreeNode so the php handler knows where to "move" across the filesystem.
When I try it this way:
the tree.setRootNode() function works but I get a 'c has no properties error' on the tree.root.reload().Code:var root2 = new Tree.AsyncTreeNode({text: 'home', id:'home'}); tree.setRootNode(root2); tree.root.reload();
Note that this is an event after the initial tree has been fully setup and rendered sucessfully.
All I really want to do is change the id of the AsyncTreeNode before reload and I'm missing a method or syntax for making it happen.
Thanks for the help!
-
29 Jun 2008 7:31 AM #8
Well from reading the forums for a while I know these threads will often end with "that was easy".
I sure wandered off into the weeds on this one. Doh!Code:tree.root.setText('foo'); tree.root.id = 'foo'; tree.root.reload();
-
29 Jun 2008 8:57 AM #9
I am not sure if changing the id is the better way but I think you are better off of just changing the baseParams and reload the node just like I said on my previous post. Its much cleaner that way and that is what baseParams is for.
-
29 Jun 2008 12:08 PM #10
Hi franciscallo - I follow your logic now. Just leave root untouched then make the changes you need to "move across" the filesystem using a combo of:
TreeNode.removeChild()
TreeNode.appendChild()
The reason I was going the other route is that I am using an AsyncTreeNode class and the nodes are built dynamically behind the scenes with php/json. Instead of iteratively removing children then appending them based on an event it was just a matter of changing the root path and reloading.
If that is a bad practice I'll use the other method.
This is clicking now, thanks for your patience.


Reply With Quote