Skip to main content

Notifications

Community site session details

Community site session details

Session Id : LhiqKPFUkFdYcgxIbfXBVb
Power Pages - General Discussions
Unanswered

Sub grid On change event

Like (1) ShareShare
ReportReport
Posted on 5 Jul 2023 11:01:10 by 2

Hi, I want to run a function on change of sub grid in power pages basic form, that is on adding related record I want to lock a field. Any suggestion how I can find on change event of that sub grid using JavaScript?

Categories:
  • Fubar Profile Picture
    7,850 Super User 2025 Season 1 on 07 Dec 2023 at 21:57:14
    Re: Sub grid On change event

    @Furban as per the example code in the link you need to put it inside a JQuery document ready (or similar).  It won't work with a standard onload as the DOM is not fully populated when onload is triggered, after the document ready triggers the subgrid container will exist in the DOM (it will then start to load its contents, when its contents are loaded you use the loaded event, a mutation observer can be used in a similar way but can also pickup as the contents are loading e.g. each row is being populated vs after they have loaded).

  • Furban Profile Picture
    9 on 07 Dec 2023 at 14:51:06
    Re: Sub grid On change event

    Thank you for introducing me to the MutationObserver, but my issue still persists.

     

    I managed to find the object, but when I insert the JS function 'onload' in the Basic Form, it is still not being called because the page loads before the subgrid within the same Basic Form. So far, I have only managed to implement the change by using a timeout. However, this solution is a bit crude, as it will display the dropdown for a split second instead of the button.

  • Fubar Profile Picture
    7,850 Super User 2025 Season 1 on 29 Nov 2023 at 21:59:38
    Re: Sub grid On change event

    @Furban the "loaded" event works on subgrids also, but the object that you attach it to is probably not entity list, just inspect the rendered page with your browsers debugger to find the subgrid object (and be careful if you have multiple subgrids, you will want to only apply it to the one you are interested in). 

    Also, a MutationObserver can be used.

  • Furban Profile Picture
    9 on 29 Nov 2023 at 11:12:56
    Re: Sub grid On change event

    I came across the same issue. I managed to run a function on the List. However, I cannot find a way of how to run a function on the sub grid.


    Have you found a work around?

  • Fubar Profile Picture
    7,850 Super User 2025 Season 1 on 06 Jul 2023 at 22:08:05
    Re: Sub grid On change event

    The Lists and Subgrids support a "loaded" event

    https://learn.microsoft.com/en-us/power-pages/configure/add-custom-javascript-list

     

    In cases where the 'loaded' event does not suffice then the other way is to implement a javascript MutationObsever

     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,743 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,079 Most Valuable Professional

Leaderboard
Loading started