You can make row selections survive in store reloads by applying the following overrides:
Ext.override(Ext.view.View, { preserveSelectionOnRefresh: true, constructor: function() { this.callOverridden(arguments); if (this.preserveSelectionOnRefresh) { this.mon(this.getStore(), { beforeload: this.beforeStoreLoadPreserveSelectionRoutine, scope: this }); } }, beforeStoreLoadPreserveSelectionRoutine: function() { var sm = this.getSelectionModel(), selection = sm.getSelection(), i = 0, l = selection.length, savedSelection = []; delete sm.savedSelection; for (; i < l; i++) { savedSelection.push(selection[i].getId()); } if (savedSelection.length) { sm.savedSelection = savedSelection; } } }); Ext.override(Ext.selection.Model, { refresh: function() { // include selections saved across store reloads if (this.savedSelection && this.savedSelection.length) { var rs = [], r, j = 0, l = this.savedSelection.length; for (; j < l; j++) { r = this.store.getById(this.savedSelection[j]); if (r) { rs.push(r); } } if (rs.length) { this.select(rs, false, true); } } this.callOverridden(); delete this.savedSelection; } });
What they do is simply save what was selected before the store reboot, and ensure that these records are re-fetched after the presentation is updated. Tested on Ext JS 4.1.2.
source share