Ext JS 4.2 Invalid row index in grouping
I am using a grid with action columns. I recently added a grouping feature. Now I get the wrong row index if I split one or more groups above my selection. those. when there is a collapsed group, all rows within the group are not counted for calculating the row index.
Below is my action column handler
{
iconCls: 'download',
align: 'center',
tooltip: 'Download File',
handler: function(grid, rowIndex, colIndex) {
console.log(rowIndex, colIndex);
var rec = grid.getStore().getAt(rowIndex);
// need to find the correct record
}
}
Any help would be appreciated
+3
source to share
2 answers
If you only want your entry, this information is already a parameter to your handler. If you really need an index, use this parameter to query your store.
{
iconCls: 'download',
align: 'center',
tooltip: 'Download File',
handler: function(grid, rowIndex, colIndex, item, e, record) {
var recIndex = grid.getStore().indexOf(record);
console.log(recIndex);
}
}
+1
source to share
{//var recIndex = grid.getStore().indexOf(record); //console.log(recIndex);
//the solution
var indexRecord = item.attributes[1].nodeValue;
var recIndex = grid.store.data.indexMap[indexRecord];
//recIndex is the true index of the record
//if you need the record of that Index, add this code
record = grid.getStore().getAt(recIndex );
}
-1
source to share