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); }
}
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
Awesome. Much appreciated.
An additional problem with that though is that while it's nice to have that property off the first row of the cell, it's not documented, whereas the ui.cell.rowIndex is in that event's description in the API documentation and the caveats you mentioned which would cause it to be inaccurate are not... also is there ever more than one row per cell - why is it cell.row[0]? Along that line, the values are not standardized across the grid packages - in some areas it's colIndex, in others it's columnIndex and so forth. Given the state of the documentation, standardizing those names would go a long way to helping developers out.
Sorry about that comment being left in there, but maybe we can change "tests" to "documents" in this case. ;)