1
votes

In ExtJs 5, while adding a new row to a grid which is already sorted, the new row is never added to the top of the grid. Is it possible, to let the store ignore the phantom record during sorting and always add it to the top/ or whatever position we specify?

2

2 Answers

1
votes

No. The reasoning I've read is that this is intentional because a store can either be sorted or unsorted, not some in-between state (the answer to if a store is sorted must be "true" or "false"). If a store has sorters, it will be kept organized. Sencha will not be changing this behavior.

It's not ideal, but before I add records to a store, I'll remove the existing sorters. It's unfortunate, but it is quick, easy, and not easily noticeable by the user. Removing the existing sorters does not reshuffle the grid's rows (since you are not applying any new sorting function). So the grid will continue to appear to be sorted, just not enforced.

var store = myStore,
    sorters = store.getSorters();

if (sorters.getCount()) {
    console.log('[' + store.$className + '] Removed Existing Sorters', {
        store: store,
        sorters: sorters
    });
    sorters.removeAll();

    store.fireEvent('refresh', store); // will remove sort icon from grid column headers
}

store.insert(newRowIndex, newRec)
1
votes

We should add the following property to the store:

autoSort: false