Tree - Disabling cache on dynamic loading

Is it possible to disable the cache on a dynamic loading tree or forcing reload the branch when opened?
What I’m trying to do is, when a branch is opened, ensuring that it is in sync with the server data without reloading the whole component.

There is no such built-in functionality
It is possible to delete the already loaded data on branch closing, so on next opening it will be reloaded.

Also, if you just need to update the branch, you can call some.load(“data.php?id=parent”), which will load the data for branch and will update the related data in the tree ( such update can only add new or update existing items )

Hi maksim,

I tried your both suggestions, removing the children on node close and (re)loading the opened node data. I think either method has problems.

I focused on the first method and I tried to fix it, I think it would be good to let you know what I found:

We need to delete all the children items of the closed node on onAfterClose and keep the folder icon with (+) sign if there was any children belongs to it. But the TreeStore.remove function has no check for webix_kids property (which we are creating that property because of the dyn loading to preserve folder views properly ) so it decrements the $count for each child deleted and finally parent.$count becomes “0”. This causes the icon to change to “document” while we want it to stay as “folder”
(related code line: webix_debug.js:10190)

I noticed that the $count property is being set to -1 for the items having webix_kids field on parse code.
(related code line: webix_debug.js:10035)

I tested adding a check for webix_kids in the remove() func. and doing the same thing as the parse function does and it appears working fine.

  remove:function(id){
  ...
    
    if (parent){
      parent.$count--;
      if (!parent.$count) {
        if(parent.webix_kids){
          parent.$count=-1;
        }else {
          parent.open = 0;
        }
        this.refresh(parent.id);
      }
    }

    //repaint signal
    this.callEvent("onStoreUpdated",[id,obj,"delete"]);
  },

Issue with reloading the node data is different. It’s causing duplicate items but I didn’t have much chance to work on it.

You are correct. The above code modification will change deleting behavior in the necessary way. The problem is - while in your case tree must preserve the “folder” state, in other scenarios deleting all child items can be just a deleting, and item change to “page” status can be a valid behavior.

Instead of patching the core lib, you can create your own tree component based on default one.

http://webix.com/snippet/34a17108

The snippet creates “atree” component, which behaves the same as normal tree, but has extra command - “reloadBranch” ( sample is not fully functional, as it can’t access real data feed, but as you can see it triggers data reloading for the branch in question )

As for problem with branch reloading - be sure that all items have “id” attribute ( I will double check this functionality as well )

Creating an inherited tree is a better idea. Thank you.