Skip to main content
Community site session details

Community site session details

Session Id :
Power Pages - Power Apps Portals
Unanswered

Target Child subgrid only

(0) ShareShare
ReportReport
Posted on by 23

Hello,

 

I am new to Powerapps Portals so please bare with me. I have added custom JS to my portal that counts the number of records in a subgrid (re-calculates each time a row is added). The issue is when I am looking up the records (parent) in the subgrid it is then also re-calculating the number of records, but I am only wanting to calculate the number of selected records (child).

 

I am currently using the subgrid name to calculate, however I want to use just the child subgrid. How can I target just the child subgrid? Thanks!

  • KellyMcLaren Profile Picture
    23 on at
    Re: Target Child subgrid only

    Hi Christian,

     

    Thanks for getting back to me. I have attached some screenshots for reference.

     

    I have a subgrid of Selected Dancers and a total that calculates the total of selected dancers on form load. When I click the "Add Dancers to routine" button, it opens the master list of dancers and re-calculates the Total Dancers number to include all the records in that Look-Up subgrid (as it calculates on load). I am only wanting it to calculate the Total Dancers I have selected, every time a new dancer has been added to the routine.

     

    This is the JS I added to achieve that. 

    $(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);
          $("#totalroutinedancers_column").val(rowTotal);
      });
  • Christian Leverenz Profile Picture
    1,214 on at
    Re: Target Child subgrid only

    @KellyMcLaren ,

    i do not quite get the question. So, is this something like: you have an order on a portalpage and a subgrid showing the order details (positions)?

    I do not know the exact structure how subgrids are rendered, but i would take a diffrent approach to that: as the id of the order is passed in as a parameter you could set up a simple fetch to count the lines and use the result directly in the javascript or even page without any javascript. 

    When positions are added you would have to recalculate. So, may be a small servciepage might be the approach for this.

    But may be i am thinking too complicated about your question 🙂 .

     

    May be a screenshot could help.

     

    Have fun,

      Christian

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

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!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Pages

#1
Lucas001 Profile Picture

Lucas001 60 Super User 2025 Season 1

#2
Fubar Profile Picture

Fubar 55 Super User 2025 Season 1

#3
surya narayanan Profile Picture

surya narayanan 35