rbf_getMaxRowIndex() equals 1 more than it should be.

Posted by Rollbase User on 17-Dec-2010 13:30

rbf_getMaxRowIndex() equals 1 more than it should be. After adding the first row to the grid, the row index should be 0, but rbf_getMaxRowIndex() is returning 1.  Field name is: "device_number_0" since it's the first row that is created, but rbf_getMaxRowIndex() is returning 1 after this first row is added.

All Replies

Posted by Admin on 17-Dec-2010 16:09

This is is correct value, just use

Posted by Admin on 17-Dec-2010 16:52

According to Chp6 documentation :

"rbf_getMaxRowIndex()
This API returns maximum value for rowIndex in grid..."

Maybe this should be changed to "returns one more than the maximum"?

I was trying to do an oncreate function like this:


function jl_addRow()
{
var rowIdx = rbf_getMaxRowIndex();
rbf_setGridValue("testfield", rowIdx, "Added through grid control");
}


but it was not working because rowIdx was always 1 more than the actual row index in the grid. In other words, it was trying to update fieldname_1 when there was only fieldname_0 in the grid.


I can always do var rowIdx = rbf_getMaxRowIndex() - 1. I just wanted to be sure it's correct, though.

Thanks.

This thread is closed