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?
@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).
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.
@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.
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?
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
WarrenBelz
146,743
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
66,079
Most Valuable Professional