Either the component's url property or its load function can be used not only for passing loading script, but can include additional loading logic in proxy objects.
Built-in Proxy Objects
There's a list of ready-to-use Webix proxy objects that can be used by adding prefixes to a loading script.
Prefixes are used before the path to you serverside script:
var list = {
view:"list"
url:"offline->load.php",
save:"offline->load.php"
};
grid.load("rest->load.php")
Methods of a proxy object are called from the url of the component it's used for:
//returns cached data for this list
list.config.url.getCache();
You can also save an instance of the necessary proxy object in a variable and call all methods from it:
var static_proxy = webix.proxy("cache", "server/datatable.php");
var grid = {
view:"datatable",
..config..
save: static_proxy,
url: static_proxy
};
if (!static_proxy.getCache())
static_proxy.setCache([
{"id":1,"title":"The Shaushenk Redemption ",
"year":"1998","votes":194865,"rating":"7.5","rank":1},
{"id":2,"title":"The Godfather",
"year":"1974","votes":511495,"rating":"9.2","rank":2}
]);
Related sample: Datatable: Cache static mode
You can add extra functionality to built-in proxy objects or redefine existing properties or methods by extending their functionality.
For instance, you can change the default place for storing cached data of an offline proxy object, which is webix.storage.local by default:
webix.proxy.myCustomName = {
init:function(){
webix.extend(this, webix.proxy.offline);
},
cache: some_place_you_choose
};
And then use it as prefix to load and save scripts:
{
view:"datatable",
url:"myCustomName->load.php",
save:"myCustomName->load.php"
}
//or, after component init
$$("datatable1").load("myCustomName->load.php");
Proxy object is a plain JSON object you create to add extra functionality to your loading and saving pattern.
It features
Proxy objects
webix.proxy.myCustomName = {
$proxy:true
prop1:value1,
...
load:function(view, callback){
//you loading pattern
webix.ajax(this.source, callback, view);
},
save:function(view, update, dp, callback){
//your saving pattern
webix.ajax().post(url, data, callback);
}
};
And then use it as prefix to load and save scripts:
{
view:"datatable",
url:"myCustomName->load.php",
save:"myCustomName->load.php"
}
//or, after component init
$$("datatable1").load("myCustomName->load.php");
Back to top