Dynamic load filtering doesnot work with custom request call to server

I have a datatable that loads in data dynamically.In the “ondatarequest” event i have my own ajax call (POST) that gets back data from the server and returns to the grid. When i try to filter the data it would return back the correct data but the datatable doesnot update the height and scrollbar according the new total_count.

I am passing in the start,count,filter,continue properties to the server. And my data has the following properties: data,pos,total_count.

And i update the filtered data through this code:

datatble.parse(filtereddata, "json");

On debugging i could find that the order(datatble.data.order) doesnot get updated correctly.

Can you please guide me in fixing the issue?
This is my datarequest event

messageResultsGrid.attachEvent("onDataRequest", function(start, count, callback, url){

filtereddata= getDataFromServer()//gets back data through ajax call
datatble.parse(filtereddata, "json");

});

On data reloading, datatable has to be cleared before loading (parsing) the new dataset:

datatble.clearAll();
datatble.parse(filtereddata, "json");

Otherwise, existing data will not be updated properly.

Also, please note that it makes sense to use the callback of async AJAX request to perform these operations.
In case of webix.ajax, you can also use the promise API.