view:select with dataColletion

Hello.
I have this:

{
view: ‘select’,
id: ‘actual_id’,
disabled: readOnly,
name: ‘actual_id’,
emptyOption: false,
label: _form.labels.act,
options: ‘/Controller/Action’,
labelWidth: 100
},

Now this Controller/Action will be called many times all over the app and eating resources actually I want to call it only once and then keep this json array locally. But how can I archive this? Is there someone who got an example for calling this array from server and the get other calls from local storage?

Thank you for any help.

Michael

did you try to use DataCollection?

var cached = new webix.DataCollection({
  url:'/Controller/Action'
});

{
  view: 'select',
  id: 'actual_id',
  disabled: readOnly,
  name: 'actual_id',
  emptyOption: false,
  label: _form.labels.act,
  options:cached,
  labelWidth: 100
},

But by doing this does the dataCollection not always receive data from server??

No, it will stay cached.

No this does not work! Because cached values returned a result object. so options in a ui.select wants an array of json …

yes, it does not work with select. but works with richselect
possibly as of using native select element.
but, if you really need cached values with select and other widgets, try to create custom proxy:
https://snippet.webix.com/32schi89

That’s correct! I can get get the option list with this but will not be select the right option while loading the form. That’s only works, when I use options:’/Controller/Action’ directly :frowning:
It’s expenditure somehow but I’ll try. is there no other way to manage this?

but will not be select the right option while loading the form.
That’s only works, when I use options:’/Controller/Action’ directly
please clarify this. there should not be any logic difference, as options:'/Controller/Action' is using other proxy in background.
is there no other way to manage this?
I do not see any other for select view.
unless you load all static data explicitly on app start and use cached values.

Thank you integral, I understand… I have to check it out

I did this:

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

And for select ui:

{
view: ‘select’,
id: ‘actual_position_id’,
disabled: readOnly,
name: ‘actual_position_id’,
emptyOption: false,
label: _form.labels.actPosition,
options: ‘getOptions->Positions’,
labelWidth: 100
},

That works but don’t forget to use webix.extend in init!

Thank you so much and keep going on your good work!!

Michael