PDA

View Full Version : [CLOSED] How to stop ReSorting in grid on cell edit.



MidnightRiders
Jan 08, 2020, 9:39 AM
Hi,

I am facing one problem on-grid edit. I am facing this problem after update version 2 to version 5.
Steps are mention below:

On version 5 use URL: https://examples.ext.net/#/GridPanel/Editable/Editor_with_DirectMethod/
1. On the grid Sort desc of column 4 - "Change" column (1.09, 0.92, 0.86, 0.73......)
2. Now change the value 0.92 to 0.75 and press tab key or click outside anywhere
Result: the Second row which you edited, it's automatically shifted on 3rd place (1.09, 0.86, 0.75, 0.73.......)

On version 2 use URL: https://examples2.ext.net/#/GridPanel/Editable/Editor_with_DirectMethod/
1. On the grid Sort desc of column 4 - "Change" column (1.09, 0.92, 0.86, 0.73......)
2. Now change the value 0.92 to 0.75 and press tab key or click outside anywhere
Result: the Second row which you edited, it's not shifted anywhere (1.09, 0.75, 0.86, 0.73.......)

I want the behavior of version 2 in version 5.

So I don't want this auto resorting when grid in edit mode.

fabricio.murta
Jan 08, 2020, 4:33 PM
Hello @MidnightRiders, and welcome to Ext.NET forums!

First, thanks for the very easy to follow instructions on reproducing your issue. It really helps us understand your problem and give you appropriate advice!

To the problem in hands, all you need to do to recall Ext.NET 2's behavior is, clear the grid sorters. It won't "de-sort" back to what it was previously, and it won't clear the last ordered column arrow in the column header cell. But if you modify the grid in another way besides editing cells, you might want to re-enable the sorters -- and for that you'd need to save it somewhere before you clear the sorters.

To clear sorters right before the first edit action, in the example you pointed, within the ext:CellEditing's Listeners block, add the following listener:



<BeforeEdit Handler="item.grid.getStore().sorters.clear();" />


In case you want the sorter to be lifted as soon as the grid is sorted (instead of waiting until an edit happens), you can just add the same handler to the grid panel's SortChange listener. For instance, still in the same example, add this Listener block within the ext:GridPanel block:



<Listeners>
<SortChange Handler="this.getStore().sorters.clear();" />
</Listeners>


With this, you would no longer need the BeforeSort listener in the editor plugin and anything else that changes the grid after it is sorted won't trigger a re-sort.

This answer is based in a discussion on the same issue undergone in the following thread from Sencha forums: How to avoid sorting when grid cell editing (https://www.sencha.com/forum/showthread.php?288640)

Hope this helps!

MidnightRiders
Jan 16, 2020, 9:49 AM
Yes, It's very helpful.

Thanks A lot. :)

fabricio.murta
Jan 16, 2020, 5:29 PM
Thanks for the feedback, and glad it helped!

We're tagging this thread as "closed", then.