Premium support for our pure JavaScript UI components


Post by H9FFDC »

I'm looking for the best way of ensuring the grid maintains sort after a data reload or data addition.

In our use case we reload the grid and the grid shows in the column header it is sorted, but the data isn't.

This can be seen on the example - https://www.bryntum.com/examples/grid/treeloadondemand/

If you sort by "Color" up, then expand "BMW" you will see the colours are incorrectly sorted.

Auto resorting isn't always desired so I looked for a config unsuccesfully.

Any config, method or workaround we can use?

Screenshot 2021-02-16 134611.png
Screenshot 2021-02-16 134611.png (54.65 KiB) Viewed 873 times

Post by mats »

Data is sorted after loading, I can see it working correctly here: https://www.bryntum.com/examples/grid/lockedcolumnstree/

Which specific scenarios are causing troubles for you now?

Ticket for the tree node on demand load issue: https://github.com/bryntum/support/issues/2384


Post by H9FFDC »

The issue we have is when we add to the store after a sort.

The user sorts a column. Then some time later the user hits a reload button. We then empty the store and add data back into it.

The column still shows a sort icon but the data isn't sorted. So our two options are, clear the sorting so visualy the column matches the data. Or we implemented a little kick as follows after some playing around.

grid.store.removeAll();
grid.store.add(modelRecords);
// Kick the sorting to resort
grid.store.sort(grid.store.sorters);

I was wondering if there was a config to keep sorting after adding data or a method to resort. The above seems to work fine. Maybe that is the prefered way?


Post by mats »

Sorting is triggered after new data is loaded, instead do:

grid.store.data = modelRecords;

Post by H9FFDC »

Awesome, thank you.


Post Reply