View Full Version : Clearing the selected cell or selected model in Grid

16 Jul 2012, 10:15 PM
Hi All,

I am usiing followind code to create my grid.

var myGrid = Ext.create('Ext.grid.Panel', {
id: myGrid ,
store: myStore,
width: '100%',
enableColumnHide: false,
enableColumnMove: true,
enableLocking: false,
sortableColumns: true,
selType: 'cellmodel',
columns: resultColumns,
columnLines: true

I am setting selType config to cellModel, which allows me to select single cell. I am using following code to read the value of that selected cell.

var sm = myGrid.getSelectionModel();
if (sm.hasSelection()) {
var selColumnNum = sm.nextSelection.column;
var selColumnField = sm.nextSelection.record.fields.items[selColumnNum].name;
str = sm.nextSelection.record.data[selColumnField];

I want to clear the selectiton under certain events. What is the code to clear the selected cell. We have a clearSelections() which is not working.

I want to do this with selType config set to 'cellmodel'.
When i clear the selection, myGrid.getSelectionModel().hasSelection() should return false.

Please help me here.

16 Jul 2012, 10:34 PM


16 Jul 2012, 10:49 PM
Thank you Farish. With this I am able to clear the selection.