2014-11-01 119 views
3

我正在使用帶有操作列的網格。最近我添加了分組功能。現在我得到不正確的行索引,如果我摺疊一個或多個組以上我的選擇。即當存在摺疊組時,組內的所有行都不計算計算行索引。Ext JS 4.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         
    } 
} 

任何幫助,將不勝感激

+0

是否使用對電網bufferedRenderer? – JesseRules 2014-11-01 21:56:32

+0

是的,我正在使用bufferedRenderer – jprism 2014-11-17 16:04:34

+0

如果商店中沒有瘋狂的記錄數量,則可以關閉緩衝的渲染器。這將解決您的計算問題。 – JesseRules 2014-11-17 16:07:53

回答

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

仍然沒有顯示正確的記錄 – jprism 2014-11-14 17:48:53

+0

它似乎在這裏工作:https://fiddle.sencha.com/#fiddle/c3e – 2014-11-21 21:58:14

+2

就像JesseRules說的,如果你不使用BufferedRenderer,那麼它會給你正確的記錄。 BufferedRenderer失敗 – jprism 2014-11-21 22:38:17

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

將此代碼放入您的處理函數中 – user3359189 2017-12-20 09:52:07