Reputation: 431
how can i get the selected cell of a Ext.grid.Panel? In ExtJS 3 it was possible via:
grid.getSelectionModel().getSelectedCell()
In Ext 4 there is
grid.getSelectionModel().selected
but this only gives me the record.
Upvotes: 3
Views: 13415
Reputation: 534
Use the beforeedit listener and context.record to get the desired row
this.editing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1,
listeners: {
beforeedit: function (obj) {
var MyColumnValue = obj.context.record.get('YourColumnName');
// or maybe to clear the value of this cell
obj.context.record.set('YourColumnName', null);
}
}
});
Upvotes: 0
Reputation: 521
I ended up needing the actual column that the user was clicking on and discovered the following:
grid.panel.columns[grid.getSelectionModel().getCurrentPosition().column]
Don't forget to apply:
selType : 'cellmodel'
to your grid to make sure you can select cells!
Upvotes: 1
Reputation: 2193
There may be a more direct way to do this but the following seems to work for me:
grid.view.getCellByPosition(grid.getSelectionModel().getCurrentPosition());
Upvotes: 5