Skip to content Skip to sidebar Skip to footer

How To Determine The Selected Cell Of A Ext.grid.Panel In ExtJS 4?

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

Solution 1:

There may be a more direct way to do this but the following seems to work for me:

grid.view.getCellByPosition(grid.getSelectionModel().getCurrentPosition());

Solution 2:

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!


Solution 3:

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);
        }
      }
 });

Post a Comment for "How To Determine The Selected Cell Of A Ext.grid.Panel In ExtJS 4?"