Getting Error in dhtmlx grid when setting setRowCol

Hi,

My scenario is :- I am adding/deleting rows into grid frequently. After deleting rows from grid when I tried to access the rowId’s list of the grid its returning correct value, but once I select particular row id then in certain cases its shows below error:-

gridCalculation1.cellById(5, 0) ‘_childIndexes’ is null or not an object Error

its returning null values for certain rowId’s but they are present in rowId’s list. Please provide me solution of this problem. My code is:-

function gridColorChange() {

for (var i = 0; i < gridCalculation1.getRowsNum(); i++) {
    cellObj = gridCalculation1.cellByIndex(i, 1);                      returning correct cellobj by cell index.
    if (cellObj.cell.innerText == 'Result') {
        SelectColor(i);
    }
    else if (cellObj.cell.innerText != 'Else') {
        var rId = gridCalculation1.getRowId(i);
        if (gridCalculation1.getRowById(i) != null) {
            gridCalculation1.setRowColor(rId, 'white');
        }
    }
    else if (cellObj.cell.innerText == 'Else') {
        var rId = gridCalculation1.getRowId(i);    getting row Id value from index value.
        if (gridCalculation1.getRowById(i) != null) { showing null value when I selected that rowId
            gridCalculation1.setRowColor(rId, 'white');
        }
    }
}

}Please help me to find solution of this problem.

You have

for (var i = 0; i < gridCalculation1.getRowsNum(); i++) { ... if (gridCalculation1.getRowById(i) != null) {

External loop iterates through row index, while inner command uses indexes as ids.
In common case there is no guarantee that there is a row id same as index value