Dynamically loading tree nodes
Enterprise applications usually have data sets that prohibit the loading of the full tree in a single JSON request. Large trees can be configured to load children on a per node basis by expanding levels on demand. A few minor changes to our code can allow us to implement this dynamic loading of node children.
When a node is expanded, the tree store proxy submits a request that contains a node
parameter with the ID of the node being expanded. The URL submitted is that which is configured in the proxy. We will change our tree store proxy as follows:
proxy: {
type: 'ajax',
url: 'company/treenode.json'
}
Note that the URL of the proxy has been changed to treenode
. This mapping, when implemented in CompanyHandler
, will load one level at a time. The first request submitted by the proxy to load the top level of the tree will have the following format:
company/treenode.json?node=root
This will return the root node's list of companies:
{ success: true, "children...