How do I change a url in onBeforeAjax?

I tried like this:

`
webix.attachEvent("onBeforeAjax",
    function (mode, url, data, request, headers, files, promise) {                
        url += [(url.indexOf("?") < 0 ? "?" : "&"), "status=", selectedStatus].join("");
    }
);
`

But the URL sent out on the request remains unchanged (i.e. it doesn’t have the “status=” query string parameter on it. Is that the approach I should use?

For what I’m trying to do, I ended up having to set the URL of the datatable to null prior to making the request, otherwise, the URL on “loadNext” gets ignored.

My goal was to have a “global” filter that can be applied alongside individual column filters. When the global filter is selected (using a menu component), I am calling loadNext and attempting to append the selected status from the global filter to the URL params list. This extra parameter is getting ignored because once the URL is set on the datatable, it uses that as the base URL and then builds up the filter/sorting params afterwards. It would be nice if “loadNext” used the URL that was provided as the base URL rather than completely ignoring it.

My “hack” was to do this:

`
table.data.url = null;
table.loadNext(200, 0, null, buildUrl(), true);
`

This forces it to reset the URL every time which is fine for me, but I kind of assumed there was an easier way to catch and modify the URL before sending it to the server. All I’m trying to do is append a query string parameter before it gets sent…

you can set url as custom proxy and send any parameter in load method.

{
  view: "datatable",
    url: {
      $proxy: true,
        load: function(table, params){
          let url = "data_url?status="+global_status;
          return webix.ajax().post(url, params);
        }
    }
}

Right, but what I want is all of the filters being compiled and put together by webix in the URL and then to just append the global status at the end. Here you aren’t taking into account any of the filters from the datatable, only the global filter. It should be like “?filter[c1]=&filter[c2]&filter[c3]&status=MY_STATUS”. So take whatever webix would normally send in the onload event and just another parameter to it.

@nathan_grier
looks like you are using get proxy (get method of ajax).
I would not recommend this method if your app is dynamic, as get method will return cached data for same filter values.
but if you are sure what you do, then you can simply use get method in url->load.
the query will be converted to ?filter[c1]=&filter[c2]&filter[c3]&status=MY_STATUS

{
  view: "datatable",
    url: {
      $proxy: true,
        load: function(table, params){
          let url = "data_url?status="+global_status;
          return webix.ajax().get(url, params);
        }
    }
}

or you can do this trick

{
  view: "datatable",
    url: {
      $proxy: true,
        load: function(table, params){
          params=params||{};
          params.status=MY_STATUS;
          let url = "data_url";
          return webix.ajax().get(url, params);
        }
    }
}

@integral awesome, thank you I will try it.