Column sorting is not included after data change

If you sort grid’s column, then reload data in grid, then user sees, that data in column is sorted, but in real data are not sorted.

There is snippet with instruction what to do to get bad state: DHTMLX Snippet Tool

I agree with @Nikolai_Dimentiev that your attitude to that product is so lazy. There are a lot of bugs and lack of features. General concept is good, but there is a lot to do still.

Hi, You will have to sort your original data array. Because the grid does not directly affect it, despite correctly rendering the sort on screen.

Basically you need to work with the “afterSort” event, sort your array and save the “type” of the sort in a variable so that you can restore the last sort made when reloading the grid.

Here’s an example:
https://snippet.dhtmlx.com/92flt4j4

The ideal is to work with the DataCollection object, because it does save the state of the data. But in the tests I did the parse() method – grid.data.parse() – didn’t work when reloading the grid (@sematik or anyone else?).

But I agree with the statements that there are many problems with both the grid and the suite in general.

I was doing some more tests, and I realized that you don’t need to sort your original array, just save the sorting state you want to restore, unless you really want to.

Updated example:
https://snippet.dhtmlx.com/6kf9w5gm

@DouglasMeirelles I can do it and I have more advanced functions because I did for example multisorting myself that DHTMLX Suite does not offer.

In my opinion writing additional code to handle that basic feature should not be necessary. I rather would like to have full sorting functionality supported by DHTMLX Library. But library does not offer so advanced features and in addition their basic functionality works with mistakes that I presented.

1 Like