I have following Editable grid with 3 records:
Using following code in JS, the getRows() always returns an empty collection.
But when I use the getTotalRecordCount() method instead, it is able to return the value "3".
It is unclear for me, why getRows() always return an empty collection ?.
The code:
function loadValue(executionContext) {
var formContext = executionContext.getFormContext();
var gridContext = formContext.getControl("nf_royalty_template_grid");
var gridOC = gridContext.getGrid();
var totalGridRows = gridOC.getTotalRecordCount();
var allRows = gridOC.getRows();
allRows.forEach(function (row, i) {
var gridColumns = row.data.entity.attributes;
gridColumns.forEach(function (column, j) {
var atrName = column.getName();
var atrValue = column.getValue();
console.log(atrName+":"+atrValue);
});
});
}
Debugging in JS
By the sounds of it, your get rows is trying to get them before the refresh is complete.
I would suggest converting your refresh function to return a promise then use a . then to get your rows post refresh completing
@SBax that was the issue. I have commented out the refresh() in form onLoad and it is now able to fetch all 3 records:
This seems like a bug
Thanks for the reply @SBax . It stills returns an empty array:
I have done a refresh() to the grid when loading the form, and invoking this piece of code "loadValue()" method when I manually change a field. I read somewhere that there might be a bug with getRows() method since it will always return an empty array if the refresh() method has been invoked on it.
Can you replace the bold text with
var allRows = gridContext.getGrid().getRows()
I'd like to see what is held in allRows if we do it this way
WarrenBelz
637
Most Valuable Professional
stampcoin
570
Super User 2025 Season 2
Power Apps 1919
473