Hello,
I am trying to get the total number of records in a grid control and I have been able to achieve this using the rbf_getMaxRowIndex2() function. However, when I delete a grid record, it still comes back with an index which I'm sure is what is expected from that function. Is there a way I can get the total number of records available in that grid?
Hello,
Did the previous sample code works? If not, there is a JQuery alternative that we are using. What we do is we count the number of rows using the grid number and then the class name of the "tr" element.
//run on delete event of grid
function funcName(gridNo){
var rowCount = $("#rbi_gridTable_" gridNo " tr[id*=rbi_gridRow]").length;
}
Thank you,
Gian
Hi,
Try the following code:
var n = rbf_getMaxRowIndex2(0); var numRows = 0; for (var rowIndex=0; rowIndex<n; rowIndex++) { var x = rbf_getGridValue2(0, 'id', rowIndex); if (x !== null){ numRows++; } } alert ('Number of rows: ' + numRows);
You can retrieve the MaxRowIndex value then iterate from 0 to MaxRowIndex.
You verify whether a row exists for a given rowIndex value by checking whether a read-only and compulsory value is not null (such as id).
This field (read-only and compulsory) must be added to the grid. If the field value is null it means that the row referenced by the row index does not exist. In that case you don't increment the row count counter.
When I try to get the Grid Value for 'id', I always get a null. So, i'm not really sure if we can get the gridValue by using an ID. Is there any other field that I could use to do this if I don't have any compulsory fields? ID seems to be a good option but it doesn't seem to work in this case.
Do you have Grid column for "id" field?
Indeed, the candidate, read-only and compulsory, field (in the example : 'id') must be added to the grid.
Hello,
Can you access the ID value inside the grid now?
Thank you,
Gian
Yes I can access the ID value inside the grid row but I dont want to show the ID.
Hello,
Did the previous sample code works? If not, there is a JQuery alternative that we are using. What we do is we count the number of rows using the grid number and then the class name of the "tr" element.
//run on delete event of grid
function funcName(gridNo){
var rowCount = $("#rbi_gridTable_" gridNo " tr[id*=rbi_gridRow]").length;
}
Thank you,
Gian