Thank you for reporting this bug. We will make it our priority to review this report.
[Ext 4.2.3] onStoreRefresh of Ext.selection.Model
[Ext 4.2.3] onStoreRefresh of Ext.selection.Model
This ticket cannot be reproduced using fiddle since it requires a remote store with filtering feature.
I have a combobox with remote data, forceSelection: true and queryMode:'remote'.
If the user filters by entering a few characters while the store is reloaded, the "Ext.selection.Model#onStoreRefresh" method is called.If one of my previously selected value does not exist anymore in the store there is a JS error in this method.
Code:
onStoreRefresh: function(){ var me = this,
selected = me.selected,
items, length, i, rec, storeRec;
if (me.store.buffered) {
return;
}
items = selected.items;
length = items.length;
me.lastSelected = me.getStoreRecord(me.lastSelected);
for (i = 0; i < length; ++i) {
rec = items[i];
storeRec = me.getStoreRecord(rec);
if (storeRec) {
if (rec.hasId()) {
me.selected.replace(storeRec);
}
} else {
me.selected.remove(rec);
}
}
}
The issue is due to the "for loop" : it is removing items from the array it loops on.Code:
for (i = 0; i < length; ++i) { ...
me.selected.remove(rec);
And this can lead rec to be undefined.A solution for this kind of problem can be to iterate the array reversly,
Code:
for (i = length-1; i >= 0 ; --i)
[Ext 4.2.3] onStoreRefresh of Ext.selection.Model
Aucun commentaire:
Enregistrer un commentaire