View Full Version : [FIXED] Grid row selection is cleared after store sync.

19 Sep 2011, 11:54 AM

Ext version tested:

Ext 4.0.5

Browser versions tested against:

Chrome 13
Firefox 3.6


If you have grid panel with an associated store, When a selected row of the grid is modified (either from row editing or from controller), after the store is synchronized (by calling store.sync() or autoSync is set to true), the selection is cleared.
You can see the behavior from the official example: http://docs.sencha.com/ext-js/4-0/#!/example/restful/restful.html

Debugging already done:

Seems like after store sync, it will call the refresh function of Model.js, and it was trying to save the old selections in order to reselect them again, but the selected row was edited, the row record was changed and the old record is no longer part of the store, the function is checking if the old record is in the store to determine if the corresponding row needs to be selected again. But the expression me.store.indexOf(selection) !== -1 is always false.
refresh: function() {
var me = this,
toBeSelected = [],
oldSelections = me.getSelection(),
len = oldSelections.length,
i = 0,
lastFocused = this.getLastFocused();
// check to make sure that there are no records
// missing after the refresh was triggered, prune
// them from what is to be selected if so
for (; i < len; i++) {
selection = oldSelections[i];
if (!this.pruneRemoved || me.store.indexOf(selection) !== -1) {
toBeSelected.push(selection); }
// there was a change from the old selected and
// the new selection
if (me.selected.getCount() != toBeSelected.length) { change = true; }
if (me.store.indexOf(lastFocused) !== -1) { // restore the last focus but supress restoring focus this.setLastFocused(lastFocused, true); }
if (toBeSelected.length) { // perform the selection again me.doSelect(toBeSelected, false, true); }

Operating System:


Phil Guerrant
1 Nov 2011, 2:02 PM
The fix for this bug will be included in Ext JS 4.1

7 Nov 2011, 11:06 AM
The fix for this bug will be included in Ext JS 4.1

Any hints on what the fix is for this until 4.1 is released? Maybe an override we can use temporarily?


Phil Guerrant
7 Nov 2011, 11:57 AM
Here's an override that patches the problem. (Tested in 4.0.7)

Ext.override(Ext.data.Operation, {
getRecords: function() {
var resultSet = this.getResultSet();
return this.records || (resultSet ? resultSet.records : null);

7 Nov 2011, 12:06 PM
Here's an override that patches the problem. (Tested in 4.0.7)

Perfect! Thanks for your quick response.

30 Dec 2011, 4:17 AM
I'm having the same kind of bug in my grid. After an update the complete line is blanked.

I see this patch should solved this issue until 4.1 release. I'm using MVC structure so it would be
very helpful if you could point out where to put this code?

thanks in advance