PDA

View Full Version : Outdated selection after grid store reload.



sergei.stolyarov
11 Apr 2013, 12:14 AM
If your grid keeps selection after reload then list of records obtained by grid.getSelectionModel().getSelection() contains the same records before and after reload, so if some selected records have been changed you'll never find it until deselect and then selecte records again.

ExtJS 4.2
Checked on Chrome, FF

evant
11 Apr 2013, 12:33 AM
There's not really enough info here, please see: http://www.sencha.com/forum/showthread.php?138165-How-to-report-a-bug

sergei.stolyarov
11 Apr 2013, 12:38 AM
Here is the problem place in the code (src/selection/Model.js, method refresh):



// Add currently records to the toBeSelected list if present in the Store
// If they are not present, and pruneRemoved is false, we must still retain the record
for (; i < len; i++) {
selection = oldSelections[i];
if (store.indexOf(selection) !== -1) {
toBeSelected.push(selection);
}


When you append record to list toBeSelected, this record (variable selection) is not a new record but an old one, you should instead use something like this to fetch updated record from the store:



// Add currently records to the toBeSelected list if present in the Store
// If they are not present, and pruneRemoved is false, we must still retain the record
for (; i < len; i++) {
selection = oldSelections[i];
if (store.indexOf(selection) !== -1) {
toBeSelected.push(store.getAt(store.indexOf(selection)));
}

vog
10 Jan 2014, 4:40 PM
I can confirm that this bug exists, because I just spent a lot of time debugging an application in which some updates after store reload didn't propagate properly through the application.

Given that this bug has been described 9 months ago, and given that sergei.stolyarov even provided a working solution 9 months ago, is there any good reason why this bugfix didn't go into into ExtJS yet?

What action is needed to increase the priority of this bug?