PDA

View Full Version : Accessing Grid row index from within Cell Editor combobox listener



harman
20 Aug 2014, 7:15 AM
Hi All,

I am using ExtJS 4.0.7. In a grid i have used the cell editing plugin.
For a column there is a combobox editor. I want to perform some actions based upon the row index of grid to which this editor belongs but i am unable to access the row index in the editor combo listener. Following is the sample


{ header: 'Light',
dataIndex: 'light',
width: 130,
editor: {
xtype: 'combobox',
typeAhead: true,
triggerAction: 'all',
selectOnTab: true,
store: [
['Shade','Shade'],
['Mostly Shady','Mostly Shady'],
['Sun or Shade','Sun or Shade'],
['Mostly Sunny','Mostly Sunny'],
['Sunny','Sunny']
],
lazyRender: true,
listClass: 'x-combo-list-small'
},
listeners: {
select: function(combo, records, index ){
console.log(index);
}
}
}

Note: i already tried grid.getSelctionModel().getSelected() but it is not working.

chamacs
20 Aug 2014, 12:15 PM
you could try:


var record = grid.getSelctionModel().getSelection()[0];
var rowIndex = grid.getStore().indexOf(record);

harman
21 Aug 2014, 3:52 AM
you could try:


var record = grid.getSelctionModel().getSelection()[0];
var rowIndex = grid.getStore().indexOf(record);


as i mentioned grid.getSelectionModel().getSelection() gives me nothing.
Isnt there a direct way of passing the row index?

Scott-1
21 Aug 2014, 8:55 AM
try this


var cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
rowIndex: -1,
listeners:{
beforeedit: function(cellEditor, context, eOpts ){
console.log(context.rowIdx);
rowIndex = context.rowIdx;
}
}
});


create a property of rowIndex on your object then set it in the before edit.