View Full Version : [DEFER][3.x] RowSelectionModel fires spurious events

4 Dec 2009, 7:36 AM
RowSelectionModel.onRefresh attempts to reselect Records with the same id as were selected prior to the refresh.

This will fire a rowselect event again when the event was already fired for that Record, and client Components have been notified and updated themselves.

Now, just doing a local sort operation will reselect the previous selection and fire the event.

Also, selection of every row fires the selectionchange event. This is then programatically fired in the onRefresh method.

This affecting my use case. They select a quote from a GridPanel, and the event triggers an Ajax request which starts the Consignment creation process, returns the JSON representation of a Consignment, and switches to the next tab to view the resulting data. Then they switch back to the Grid tab, idly click a header to sort the Grid, and boom! It recreates the consignment all over again.

This is a case for individually suspendable events as requested in my other thread.

Then the fix would be

onRefresh : function(){
var ds = this.grid.store, index;
var s = this.getSelections();

// In the loop, we are reselecting previously selected IDs, so don't re-fire the rowselect event.

// Each individual selectRow call would fire the event otherwise!

for(var i = 0, len = s.length; i < len; i++){
var r = s[i];
if((index = ds.indexOfId(r.id)) != -1){
this.selectRow(index, true);


if(s.length != this.selections.getCount()){
this.fireEvent('selectionchange', this);

Either that or call selectRow passing a new 4th parameter:

selectRow : function(index, keepExisting, preventViewNotify, /* private */ suspendEvents){
if(this.isLocked() || (index < 0 || index >= this.grid.store.getCount()) || (keepExisting && this.isSelected(index))){
var r = this.grid.store.getAt(index);
if(r && (suspendEvents || this.fireEvent('beforerowselect', this, index, keepExisting, r)) !== false){
if(!keepExisting || this.singleSelect){
this.last = this.lastActive = index;
if (!suspendEvents) {
this.fireEvent('rowselect', this, index, r);
this.fireEvent('selectionchange', this);

Not critical, let's just remember this for 3.1.1

4 Dec 2009, 7:45 AM
There are more RowSelectionModel methods where this needs to be fixed (here is an old Ext 2.2 bugreport (http://www.extjs.com/forum/showthread.php?p=223311#post223311) on the same issue).

4 Dec 2009, 8:12 AM
I'm going to post an FR for individual event suspension. I think it's a cool idea.

Jamie Avins
4 Dec 2009, 4:37 PM
Slate it for 3.2 Nige.