Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1460
rowIndex is not zero-based but the methods expecting the index of the row are...
posted

Is this normal or something that's happening to me locally?  When I retrieve the rowIndex it starts with 1 but when I have to pass the rowIndex to another method it expects 0 for the first row.  The index for cells is zero-based.

 

 

{ name: "Selection",                            
   mode: "cell",                            
multipleSelection: false,                            
activation: true,                            
cellSelectionChanged: function (evt, ui) {                                
if (ui.cell.columnKey === 'NextRound') {                                    
var actualRowIdx = ui.cell.row[0].rowIndex - 1 // rowIndex is not zero based, but other methods are and expect a zero-based index (since Infragistics no longer tests their products)                                    
var myCell = grid.igGridSelection('getCellValue', actualRowIdx, 'NextRound');                                    
var dataview = grid.data('igGrid').dataSource.dataView();                                    
var myVal = dataview[actualRowIdx]["NextRound"];                                   
grid.igGridSelection('selectCell', actualRowIdx, ui.colIndex);                                    
grid.igGridUpdating('startEdit', actualRowIdx, ui.colIndex);                                   
grid.igGridUpdating("setCellValue",actualRowIdx, 'NextRound', !(myVal));                                    
dataview[actualRowIdx]["NextRound"] = !(myVal);                                
}

}

Parents
  • 6279
    Suggested Answer
    posted

    Hi Chris,

    I did investigate the issue with several cells and I saw that the zero-based index was properly used for the cell. 
    However, the issue stems from the fact that the TR object's rowIndex property calculates the row's index within the TABLE element, while also honoring all TR-containing table sections (THEAD, TFOOT and all tbodies).

    This is why another property exists: sectionRowIndex - it's meant to be grounded to the current table section and thus the solution to your issue.

    So the code would look like:

    var actualRowIdx = ui.cell.row[0].sectionRowIndex; 
    //or in case you want to use the row index calculated by the igGrid framework instead
    var actualRowIdx = ui.cell.rowIndex;
    // We test our products and zero-based indices are still used as rule of thumb ;)
    

    Cheers,
    Borislav
     

Reply Children