Ext JS 4.2分组中的行索引不正确

问题描述 投票:3回答:2

我正在使用带有动作列的网格。最近我添加了分组功能。现在,如果我在我的选择上方折叠了一个或多个组,则会得到错误的行索引。即,当存在折叠组时,组内的所有行都不计算计算行索引。

下面是我的动作列处理程序

{
    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                                  
    }
}

任何帮助,将不胜感激

javascript extjs grouping
2个回答
1
投票

如果您只需要获取记录,那么该信息已经是您的处理程序的参数。如果您确实需要索引,请使用该参数查询商店。

{
    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
投票
{//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 );                         
}
© www.soinside.com 2019 - 2024. All rights reserved.