Update datatable after server response

Hi All,
I am unable to force update of a datatable (with their server filters) after an ajax response.

Please see:
https://snippet.webix.com/31555hdr

Any help would be appreciated!
Thanks
Perez

Comments

  • As a licensed user, I'm a bit surprised that no one webix guru take in carge this question.
    So, I try again, but sure, for the last time:

    As stated in the docs:

    https://docs.webix.com/api__ui.datatable_filterbyall.html

    refilters DataTable by all specified filters

    but doing some debug on the source code, it seems that it not "refilter", but simply filter if the filter is different than the previous one:

    url += params.join("&");
    if (this._feed_last.url !== url){
    this._feed_last.url = url;
    this.load(url, final_callback);
    } else {
    this._load_count = false;
    }

    Again:
    what is the best way to force a reload of a datatable preserving they current parameters (i.e.. start=300&count=150&filter[field1]=77&filter[field2]=15)?

    Thanks
    Perez

  • I use filterByAll widely and have never had a problem. maybe since I don't use get method.
    in your case try to register a fake filter (on filterless visible column) which always returns different value (e.g. Date.now() or webix.uid())

    table.registerFilter({}, {columnId:"some_col"},{
        $server: true,
        getValue:function(){return webix.uid();},
        setValue:function(){}
    });
    
  • Thanks @integral
    fake filters woks fine, I think the problem may be in the GET
    by the way, even if the request is not issued to the server, both events woks as expected:

    onAfterFilter
    onBeforeFilter

  • You can have a fake filter for some column, which will ensure that the filter state changes.

    Normally the Datatable will not make a request for the same data unless it is explicitly stated. For instance, you can compose the loading URL from the widget state:

    var filter = $$("tbl").getState().filter;  //filters state
    var count = $$("tbl").config.datafetch;    //number of records to fetch 
    var start = $$("tbl").count;               //current data count
    

    And, using the above data, issue an Ajax request manually:

    webix.ajax($$("tbl").data.url+"?start=start&count=count&...").then(function(data){
        webix.ajax.$callback($$("tbl"), callback, "", data.json(), -1);
    });
    
  • Thanks @Nastja
    now the process is perfectly crear.
    It works as expected.

    Thanks!
    Perez

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!