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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Target Child subgrid only
Power Pages
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!

Categories:
I have the same question (0)
  • Christian Leverenz Profile Picture
    1,214 on at

    @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

  • KellyMcLaren Profile Picture
    23 on at

    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);
      });
    Screen Shot 2021-11-16 at 3.01.39 PM.png
    Screen Shot 2021-11-16 at 2.59.29 PM.png
    Screen Shot 2021-11-16 at 3.02.52 PM.png

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
11manish Profile Picture

11manish 50

#2
Valantis Profile Picture

Valantis 26

#3
omkarsupreme Profile Picture

omkarsupreme 24

Last 30 days Overall leaderboard