PDA

View Full Version : DataViews select method clears the old selections even when selection is cancelled



jokelas
17 Oct 2010, 5:52 AM
Description:

I noticed that the DataViews select-method clears the old selections even when the beforeselect handlers return false and the new selection is cancelled. Is this the wanted behaviour?

I checked that in the RowSelectionModels selectRow-method does this action differently... and in my opinion "the right way".


Ext version tested:

Ext 3.3


Adapter used:

ext


css used:

only default ext-all.css


Browser versions tested against:

FF3 (firebug 1.7X.0a3 installed)


Operating System:

Win7 64


Possible fix:


Select now:


var node = this.getNode(nodeInfo);
if(!keepExisting){
this.clearSelections(true);
}
if(node && !this.isSelected(node)){
if(this.fireEvent("beforeselect", this, node, this.selected.elements) !== false){
Ext.fly(node).addClass(this.selectedClass);
this.selected.add(node);
this.last = node.viewIndex;
if(!suppressEvent){
this.fireEvent("selectionchange", this, this.selected.elements);
}
}
}



Select after my modifications:


var node = this.getNode(nodeInfo);

if(node && !this.isSelected(node)){
if(this.fireEvent("beforeselect", this, node, this.selected.elements) !== false){
if(!keepExisting){
this.clearSelections(true);
}
Ext.fly(node).addClass(this.selectedClass);
this.selected.add(node);
this.last = node.viewIndex;
if(!suppressEvent){
this.fireEvent("selectionchange", this, this.selected.elements);
}
}
}


I do not know if this is the right way to do it, but it works for me :).

- Simo