1

I am using Webix UI framework. I am trying to find the best way to modify the query sent to the server before filtering/requesting data from the server on a datatable component. The same should apply for dataview and other components.

I figured out that modifying the passed parameters on 'save' is straightforward:

onBeforeUpdate:function(id, o) {
  o.data.newVariable = newValue;
}

and I can add up any number of fields in the post request.

When retrieving data though, that is not so clear on were to access the data to be used in the query. An approach will be with registerFilter but I believe this requires creation on a dummy column which I would prefer to avoid.

I have figured that I can do that easily with:

onBeforeFilter: function() {
  this.data.url = "script.php?field=value";
}

and webix takes care to keep my query string in tact and append to it the rest of the filter parameters.

What would be the most proper way to do this? Is there any other way to access and modify the data in the query before filtering?

Please share your thoughts.

4

1 回答 1

1

You can use Data Proxy

http://docs.webix.com/desktop__server_proxy.html#creatingcustomproxyobjects

It is a piece of code, which will work as a proxy between a component and a server-side code. Each time when a component will need to send a request to a server side, a method of proxy will be called. So you will have a full control, which data to send to a server side.

webix.ui({
    view:"list",
    url:{
        $proxy:true,
        load:function(view, callback, state){
                //any data loading pattern here
                webix.ajax("some.php?a=1", callback, view);
        }
    }
});
于 2016-02-15T12:56:06.047 回答