Javascript Ext JS 4.2分组中的行索引不正确
我正在使用带有动作列的网格。最近我添加了分组功能。现在,如果在所选内容上方折叠一个或多个组,则会得到错误的行索引。也就是说,当有一个折叠的组时,组内的所有行都不会用于计算行索引 下面是我的操作列处理程序Javascript Ext JS 4.2分组中的行索引不正确,javascript,extjs,grouping,Javascript,Extjs,Grouping,我正在使用带有动作列的网格。最近我添加了分组功能。现在,如果在所选内容上方折叠一个或多个组,则会得到错误的行索引。也就是说,当有一个折叠的组时,组内的所有行都不会用于计算行索引 下面是我的操作列处理程序 { iconCls: 'download', align: 'center', tooltip: 'Download File', handler: function(grid, rowIndex, colIndex) { console.log
{
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
}
}
如果您只需要获取您的记录,我们将非常感谢您的帮助,这些信息已经是处理程序的参数。如果确实需要索引,请使用该参数查询存储
{
iconCls: 'download',
align: 'center',
tooltip: 'Download File',
handler: function(grid, rowIndex, colIndex, item, e, record) {
var recIndex = grid.getStore().indexOf(record);
console.log(recIndex);
}
}
您是否在网格上使用bufferedRenderer?是的,我使用bufferedRenderer如果存储中没有大量记录,您可以关闭缓冲渲染器。这将解决您的计算问题。谢谢您的回复。不幸的是,商店里有大量的唱片。无法关闭。在本例中,这是ExtJS4.2.x中的一个bug吗?它是bufferedRenderer。它不会在网格上创建它,直到您向下滚动。您可以使用数据获取存储,并在那里进行计算,因为所有记录都在存储中。在Extjs5中,他们通过允许模型本身中的公式解决了这一问题。您可能希望尝试findRecord并在存储上对此记录进行索引,以获得正确的位置。就像JesseRules说的,如果你不使用BufferedRenderer,它会给你正确的记录。使用BufferedRenderer失败
{//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 );
}