webix.DataCollection and columns option

I have many tables with options for filtering in columns this options are loaded from server while using this:

let collect = new webix.DataCollection({
scheme:{
$init:function(obj){
obj.size = obj.size*1;
}
},
url: url
});

But I don’t want to load this options always from server but better from local storage when no changes are done. So my question is what is the best praxis to do this??

Thank you so much

Michael

@Michael
try this scenario

let collect = new webix.DataCollection({
  scheme:{
    $init:function(obj){
      obj.size = obj.size*1;
    }
  },
  data: new webix.promise((res, rej)=>{
    if(DATA_NOT_CHANGED){
      res(some_saved_data);
    } else {
      res(webix.ajax().post(url));
    }
  })
  //url: url
});

Thanks a lot. I’ll try this out.

This doesn’t work properly. In a view:select ui options want to get an array of json objects not a result from the other hand I thought dataCollect stores it’s values by it self…
There is a big question!!!

Hello, @Michael

I’m sorry for the delay with the answer. I can see, that you found the answer to a similar question in this [discussion] (https://forum.webix.com/discussion/40105/view-select-with-datacolletion)
Did that solve the issue?

Hello @AlenaLisava .
Yes, no problem. I found a solution but in this (discussion Link your said) I have to use webix.storage.local. But is a good way to have it without storage.local in proxy?

I would not recommend using webix.storage in such scenario.
as values will be deserialized on each call.
instead try to use it on first call and store values in some map.

let optionsCache = {};
webix.proxy.getOptions = {
  init:function(){
    webix.extend(this, webix.proxy.rest);
  },
  $proxy:true,
  load:function(view,params){
    let source = this.source;
    let result = optionsCache[source];
    if(result) {
      return result;
    }
    result = webix.storage.local.get(source);
    if(result){
      return optionsCache[source] = result;
    }    
    let url = '/'+source+'/getOptions';    
    return optionsCache[source] = webix.ajax(url,function(text,data){
      console.log('load '+source+' options from server');
      webix.storage.local.put(source, optionsCache[source] = data.json());
    });
  }
};

Thank you integral.
That’s help me a lot!
Michael