View Full Version : [SOLVED] TreePanel: How to load all data in one AJAX request?

1 Mar 2010, 8:56 AM
I'm trying to master the TreePanel object, but I didn't find how to load all the data of the TreePanel in one request.
It's embarrassing because I need to browse this data through many levels, so with the actual loading mode I need to do many request, one by sub-level and it's not acceptable.

Can someone can help me for this issue ?

Thank you!

1 Mar 2010, 11:47 AM
1) Look at the TreeLoader class.

2) Create a TreeLoader object with all the custom stuff you want. You might want a 'beforeload' handler to set a few custom parameters, etc. (node types and id's):

For example, in one of my apps, my tree has a click/expand handler on it to detect the selected node. Then I have a 'beforeload' handler in my TreeLoader that sets any 'selected node' information necessary to retrieve the relevant records.

3) Create the Tree and pass the TreeLoader object to it.

4) Enjoy.

2 Mar 2010, 12:33 AM
Thank you! I set all the children in one response, and now it does only one request to retrieve all the records. It's exactly what I needed! :)