Opened 10 years ago

Closed 10 years ago

#14552 closed defect (wontfix)

dijit.Tree's ForestStoreModel's onSetItem needs be changed

Reported by: Jean-Rubin Leonard Owned by:
Priority: high Milestone: tbd
Component: Dijit Version: 1.7.1
Keywords: dijit tree forestStoreModel Cc:
Blocked By: Blocking:


Hi, the onSetItem method of ForestStoreModel? is supposed to be overridden by the developper to tailor to the need and to make the tree's behavior more efficient. By default, the model will requery the root node everytime there's a change in any node of the tree. Since a tree can have several nodes, that triggers a lot of traffic with the server. That behavior is expensive. In the below exemple, I test to see if the node that just changed is a root node and in that case only do I requery. :

I have a module that inherits from ForestStoreModel? that has the following method: onSetItem:function(/* item */ item, attribute, oldValue, newValue){

if((item.node_type) && (item.node_type.toLowerCase() == 'scenario')){

this.inherited(arguments); this._requeryTop();





Unfortunately, in the else, I call this.inherited(arguments); ForestStoreModel?'s original onSetItem is called. Since it contains the following: this._requeryTop(); this.inherited(arguments); The heavy requerying to the database still takes place.

If in my object's onSetItem I do not call this.inherited(...) in the else branch of the if, then It's fine, I don't get those multiple calls. The tree behavior (in conjunction with the jsonRestStore) is then broken, because the onSet notification is not sent.

We therefore have to choose between an unacceptably verbose tree of which the view component gets updated fine or a more efficient tree with a view that doesn't get updated (again with the implementation with a jsonRestStore). The only way I have found to make this work was to remove the this._requeryTop(); from ForestStoreModel?'s onSetItem. By doing this, the constant requerying is removed but I still get access to all the stuff treeStoreModel does to pass on the onSet notification.

As a permanent solution, I therefore suggest that that line should be removed from ForestStoreModel? to ensure we can get access to the full functionality of treeStoreModel's onSetItem. Basically what I'm saying is that the process to remove the constant requerying is incomplete if we leave that aforementionned line in ForestStoreModel?. It should be removed. Thank you and happy new year.

Change History (1)

comment:1 Changed 10 years ago by bill

Resolution: wontfix
Status: newclosed

I'm not going to change that code. That line needs to be there because an update to an item can make it start or stop matching the query for top level items.

Your options are:

  • in your subclass, call dijit.tree.TreeStoreModel.prototype.onSetItem.apply(this, arguments) rather than this.inherited(arguments);
  • override ForestStoreModel.onSetItem() to do what you want, assuming no other code is depending on the current behavior.
  • override requeryTop() to do nothing if this.dontRequeryTop is set, and then (temporarily) set that flag from your own code
  • use ObjectStoreModel instead; ForestStoreModel will be deprecated starting in 1.8, and removed in 2.0.
Last edited 10 years ago by bill (previous) (diff)
Note: See TracTickets for help on using tickets.