DataTable: filter and sort dynamically added data

Hello guys, let me first say you did an amazing job implementing data grid!

In my scenario I use datatable to present 30-50k rows and I’m pushing updates to the data to keep it up to date.
Here is the problem: if user filters or sorts data then when I add new rows they disregard filtering and sorting. I created a simple snippet to illustrate the issue: http://webix.com/snippet/b33c2577. If, for instance, you select in Year filter ‘1987’ you will only one row then if you press “Generate Data” you will see that the filter is still active and there are new rows in the grid with year different from ‘1987’. Same behavior for sorting.

Is that a bug or I’m missing something?

In case of filtering - this is expected behavior. Newly added rows always visible. It is quite easy to change this behavior to one, necessary in your case, just add

$$("grid").filterByAll();

after adding new rows. It will reapply current filtering settings.
http://webix.com/snippet/7db6ac11

Case with sorting requires a bit more coding
http://webix.com/snippet/4380ed2f

Now it requires an additional event handler to save sorting state, I think it will be improved in the next updates ( we will add an API to get sorting state of the grid )

Thank you a lot, that helped.

@maksim what’s the best practise to update the dataset dynamically?

Imagine you have your datatable built and working. Now you request the new state of the dataset, so you must replace it by the new one.

I’m currently doing it with:
$$('data').clearAll(); $$('data').define({ data: [] })
but not sure if it’s consistent enough so I can go updating dynamically data and keeping filters and sorts.

By the way, it would be a good post to enhance the documentation.

I’ve accomplished synching the new data (considering I’m using React), doing the following: https://webix.com/snippet/913b3b34.