Dojox JsonRestStore loads the same thing multiple times

I use the lazy load tree in a web application project; however, I came across some strange behavior. It seems that a simple tree with three levels causes 7 queries for the root structure. Looking at the official JRS test, I'm not sure if this is normal or not.

Take 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 find it, my browser makes 5 requests for the root structure. My only question is why?

Change It is worth noting that this does not happen with dojo 1.5 or lower.

Here's what it looks like in the inspector (Chrome): Chrome inspector

+1
source share
2 answers

Finally, I found a solution to this problem, thanks to this post in dojo's interest: thisisalink .

basically, with dojo 1.6, dijit.tree.ForestStoreModel has been extended with several new hook-like features (I think due to working with TreeGrid). One of them, onSetItem is called as soon as the node tree expands (in this way, preLoaded is formed for full load when using the lazyLoading repository). In the base implementation, this function calls _requeryTop() , which queries all the root elements.

for our application, we could simply replace dijit.tree.ForestStoreModel our digicult.dijit.tree.ForestStoreModel implementation, where onSetItem and onNewItem do not call this._requeryTop .

Unfortunately, this is not enough to subclass ForestStoreModel, since there are calls to this.inherited(arguments); in functions that cannot be easily replaced, so we had to copy the entire class (copy class, rename, comment out two lines - the easiest way to fix it for a long time :-)) - this may force us to redesign the class again as soon as we update dojo to even newer version.

+1
source

I also ran into performance issues with the dijit tree when a tree with 10,000+ nodes was loaded immediately, with ~ 3,000 items at the highest level. The tree had only one dummy root node, which loads the entire tree on the first click through an ajax call.

In this case, it took more than 1 minute to create the tree, and I got the message β€œStop running this script dialog" in IE8.

After applying several optimization steps, the tree now loads in 2 seconds in all major browsers (including IE8-IE11).

The first optimization I did was to use dijit/tree/ObjectStoreModel as a tree model and dojo/store/Memory as a data store.

This accelerated the insertion of ajax response json nodes into the tree data store.

The second optimization concerned the slow creation of tree nodes. It took more effort to fix:

I had to extend dijit/Tree and override the setChildItems() function (its part, which calls the _createTreeNode() function).

I kept all the logic of setChildItems() unchanged, just added the parallelization of creating tree nodes using this technique:

http://www.picnet.com.au/blogs/Guido/post/2010/03/04/How-to-prevent-Stop-running-this-script-message-in-browsers.aspx

Hope this helps, if necessary, I can post the source code of my workaround

0
source

All Articles