PDA

View Full Version : Lazy load tree



TheBigOnion
24 Jun 2010, 5:41 AM
Hello,
does anyone know of an example to show me how to lazy load a tree?
I want it so that when the user clicks on a folder, my php page will be called with the new parameter.

Thanks,
Michael

mankz
24 Jun 2010, 5:50 AM
How about this example: http://www.sencha.com/deploy/dev/examples/tree/reorder.html

CrazyEnigma
24 Jun 2010, 7:35 AM
Note: the "id" of the node objects is the value that is sent to the server as (node: <id>), but the return from the server is "id".

Animal
24 Jun 2010, 7:46 AM
The name of the parameter is configurable.

TheBigOnion
24 Jun 2010, 8:50 AM
Ok,
so I didn't see anything in the js of that example called "node:". Where does it tell the tree to call the url when the folder is clicked? And where does it load that folder with the children when the folder is clicked?

Thanks...

TheBigOnion
24 Jun 2010, 9:37 AM
so i have my tree:
Root
-- A
-- B
-- C
and I load it with:


loader: new Ext.tree.TreeLoader({
dataUrl: 'loadTree.php'
}
I need to figure out how when someone clicks "B" to call 'loadTree.php' with a parameter 'arg1=B' and then populate the children for "B".

Can anyone help me figure this out?

Thanks

Animal
24 Jun 2010, 10:37 AM
Use Firebug to see what it sends.

Then code your loadTree.php accordingly

CrazyEnigma
24 Jun 2010, 10:41 AM
I know that for other posts, avoid "id" like the plague, but "id" in this case is different from the div's "id".

You need to specify "id". As mentioned, if you don't customize your TreeLoader, this "id" will be sent to the server as a parameter called "node". Animal did say that you can configure this.

Did you specify these nodes to be non-leafed? As in:


leaf: false


Did you take a look at the TreeLoader (http://www.sencha.com/deploy/dev/docs/?class=Ext.tree.TreeLoader) and TreeNode (http://www.sencha.com/deploy/dev/docs/?class=Ext.tree.TreeNode) documentation?