PDA

View Full Version : Grid with one row selected



sofway
2 Aug 2010, 12:54 PM
Hi,
I need a grid with one row selected always. When i hit ctrl+click on a row selected, it gets "deselected".
I need to block this behavior.

Thanks

darthwes
2 Aug 2010, 4:21 PM
hook select event.

Your welcome.

Condor
3 Aug 2010, 12:04 AM
No, that won't work. Normally you would write a 'beforerowdeselect' event handler and return false if only one row was selected.

Unfortunately, RowSelectionModel doesn't have a beforerowdeselect event, so you will need to do an inline override of deselectRow, e.g.

selModel: new Ext.data.RowSelectionModel({
singleSelect: true,
deselectRow: function(index) {
if (this.selections.length == 1 && this.selections[0] == this.grid.store.getAt(index)) {
return;
}
this.constructor.prototype.deselectRow.apply(this, arguments);
}
}
}