I’m using a lazy loading tree in a web app project; however, I’ve ran into some strange behavior. It seems a simple tree with just 3 levels causes 7 requests for the root structure. After looking at the official JRS tree test, I’m not sure whether this is normal or not.
Have a look at this example:
http://download.dojotoolkit.org/release-1.6.1/dojo-release-1.6.1/dijit/tests/tree/Tree_with_JRS.html
When I visit it, my browser makes 5 requests for the root structure. My only question is why?
Edit: Worth mentioning is this doesn’t happen with dojo 1.5 or below.
Here’s what it looks like in the inspector (Chrome):

finally I found a solution to this problem, thanks to this post on dojo interest: thisisalink.
basically, with dojo 1.6 the dijit.tree.ForestStoreModel was extended with a few new hook-like functions (I guess because of the work done with the TreeGrid). One of these,
onSetItemis called once a tree node is expanded (thus going form preLoaded to fully loaded when using a lazyLoading store). In the basic implementation, this function calls_requeryTop(), which requeries all root items.for our application we could simply replace
dijit.tree.ForestStoreModelwith our implementationdigicult.dijit.tree.ForestStoreModel, whereonSetItemandonNewItemdon’t callthis._requeryTop.Sadly it’s not enough to subclass the ForestStoreModel, as there are
this.inherited(arguments);calls in the functions which can’t be replaced easily, so we had to copy the whole class (copy class, rename, comment out two lines – easiest fix in a long time 🙂 ) – this may force us to redesign the class again once we update dojo to an even newer version.