grid.getRowsNum breaks grid.cells

grid.cells is detecting 1 less row count than grid.getRowsNum.

Using a for loop to traverse all the rows in a grid:

for (var i = 1; i <= grid.getRowsNum(); ++i) {
cellText = grid.cells(i,0).getValue(); // this function breaks!!!

getRowsNum returns a value 1 higher than grid.cells(i,0) accepts as are in the grid.

This occurs after the grid has been displayed, All rows selected, All rows deleted, All rows re-added using:

for (var i = 0; i < choiceArray.length; ++i) {

What is the solution? I need getRowsNum to return a value that I can use in grid.cells.

I found that selecting all the rows and deleting them more than once throws many errors.

A work-around is to delete them individually each time. This method works no matter how many times it is done on the same grid.

Also storing the number of grid.getRowsNum and tracking it myself in a global var keeps the code from crashing, instead of using grid.getRowsNum after they have all been deleted and some re-added.