View Full Version : TreePanel, load on demand

22 Aug 2011, 1:44 AM

I would like you have a tree, which only loads 1 level at a time.
So when a user click on expand on a node, extjs will call a service and populate with the leaf nodes of that node.
How can I acchieve this? For now, i'm only able to load all of the nodes at once, which is a huge performance hit if there is alot of nodes.


22 Aug 2011, 7:19 PM
You'll need to configure your tree's store to be something like this:

new Ext.data.TreeStore({
proxy: {
requestMethod: 'GET',
type: 'ajax',
url: 'tree.json'
root: {
text: 'Root'

As each node is expanded it will send a request to the server of the form tree.json?node={id} where {id} is the id of the node.

The response would be a JSON array of child nodes. If a node is a leaf then include leaf: true, otherwise it will appear expandable in the UI.

All sorts of customizations to this process are available but that's the heart of it.