Skip to main content
Community site session details

Community site session details

Session Id : eiQkICoMbEWxKrhNWNAxlV
Power Apps - Building Power Apps
Unanswered

Editable grid getRows() method returns always an empty collection

Like (0) ShareShare
ReportReport
Posted on 31 Aug 2022 16:37:03 by 8

I have following Editable grid with 3 records: 

OsmanEsen_1-1661963454472.png

 



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". 

OsmanEsen_2-1661963490188.png


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

OsmanEsen_0-1661963345978.png



Categories:
  • SBax Profile Picture
    1,348 on 31 Aug 2022 at 18:01:35
    Re: Editable grid getRows() method returns always an empty collection

    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 

     

  • Osman Esen Profile Picture
    8 on 31 Aug 2022 at 17:55:07
    Re: Editable grid getRows() method returns always an empty collection

    @SBax that was the issue. I have commented out the refresh() in form onLoad and it is now able to fetch all 3 records: 

    OsmanEsen_0-1661968308823.png


    This seems like a bug

  • Osman Esen Profile Picture
    8 on 31 Aug 2022 at 17:38:02
    Re: Editable grid getRows() method returns always an empty collection

    Thanks for the reply @SBax . It stills returns an empty array: 

    OsmanEsen_0-1661967196722.png

    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. 

  • SBax Profile Picture
    1,348 on 31 Aug 2022 at 17:06:42
    Re: Editable grid getRows() method returns always an empty collection

    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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 637 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 570 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 473