web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Count number of rows i...
Power Pages
Unanswered

Count number of rows in subgrid and update text field with that value

(0) ShareShare
ReportReport
Posted on by 23

Hello,

I am trying to get the row count of my subgrid and push that number to a text field in the same form. Each time a new row is added to the subgrid, I would like that number to update in the text field. 

Categories:
I have the same question (0)
  • H V Profile Picture
    1,510 on at

    Hi @KellyMcLaren 

     

    • Go to Your Basic Form
    • Click on Additional Settings
    • Add below code in Custom JavaScript
    $(document).ready(function() {
    	var entityGrid = $(".entity-grid.subgrid").eq(0);
    	entityGrid.on("loaded", function () {
    		var rowTotal = 0;
    		entityGrid.find("table tbody > tr").each(function(index, tr) {
    			rowTotal++; 
    		});
    		//alert(rowTotal);
    		$("#textfieldlogicalname").val(rowTotal);
    	});
    });

     

    Please replace "textfieldlogicalname" with your text field logical name in the code.

     

    --------------------------
    If you like this post, give a Thumbs up. Where it solved your query, Mark as a Solution so it can help other people!

  • KellyMcLaren Profile Picture
    23 on at

    Hi @hardikv 

    This works great with one exception.

    As soon as I open the lookup to add a new row to the subgrid, it calculates the rows in that lookup pop up and replaces the total calculated number of subgrid rows. The calculation intially does calculate correctly, until I add another row to the subgrid. See screenshots for example. I only want to calculate the records I've selected. Any suggestions? 

  • KellyMcLaren Profile Picture
    23 on at

    Hey @hardikv  I just wanted to check-in to see if you have any suggestions on how to calculate just the records I have selected, not the master list of records that shows up when I click the "add" button in the subgrid. Thank you!

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Pages

#1
Fubar Profile Picture

Fubar 78 Super User 2025 Season 2

#2
Jerry-IN Profile Picture

Jerry-IN 75

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard