Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

Capturing the onLoad event of the Associated Grid View

Posted on by 80

Does anyone have an idea how to capture the onLoad event of the associated grid like you can with grid views on the normal form?

Annotation-2020_2D00_05_2D00_05-092209.png

For a gridview I place on the form I can user this https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/grids/gridcontrol/addonload

But in the case of the associated view I don't know the name of the grid because It's a default system grid so I cannot bind JavaScript to It. In this case I need to capture the onLoad event so I can update a total hours field after a delete action. This already works of the gridview I placed on the form myself.

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: Capturing the onLoad event of the Associated Grid View

    Hi,

    You can hide that button from ribbon workbench. Create new solution ->Add subgrid entity in solution->open ribbon workbench->Choose solution-> Navigate to Sug grid section of ribbon->right click on Open aasociated grid view->Hide->Publish changes

    CQ12.PNG

    If found helpful, Please mark my answer verified.

  • Johao Larios Profile Picture
    Johao Larios 1,795 on at
    RE: Capturing the onLoad event of the Associated Grid View

    Edwin,

     Thanks for elevate this to Microsoft directly.

    Please, once you get an answer could you share it over her and mark this thread as answered? so if any one else is looking for this could see the information.  

    Have a nice day.

    Regards,

  • Edwin Hebbink Profile Picture
    Edwin Hebbink 80 on at
    RE: Capturing the onLoad event of the Associated Grid View

    Thanks for trying to help and I know that's how you refresh a page because that works on the grid I placed on the form but this grid I'm talking about is the standard MS grid and when I delete a record there I have now way of triggering a JavaScript.. That is the whole question. I'll try to send the question to MS.. Thanks..

  • Johao Larios Profile Picture
    Johao Larios 1,795 on at
    RE: Capturing the onLoad event of the Associated Grid View

    Edwin,

    Thanks for the quick response. Now I understand your issue. unfortunately there is no supported way to access the onload event for those grids. I would suggest you open an idea here: experience.dynamics.com/.../

    To refresh the page after do the webapi thing that I mentioned, you can use this:

    formContext.data.refresh(save).then(

    function () {

    // success

    }, function (error) {

    // failure

    // you get more information about why saving data failed in error argument:

    var errorCode = error.errorCode;

    var errorMessage= error.message;

    alert(errorCode +" "+error.errorMessage)

    }

    );

    docs.microsoft.com/.../refresh

    this will retrieve to the form the newer data.

    If this solved your question, please mark it as answered.

    Let me know if you have any questions.

  • Edwin Hebbink Profile Picture
    Edwin Hebbink 80 on at
    RE: Capturing the onLoad event of the Associated Grid View

    Hi Johao.. The problem is that I have a total hours field on the parent entity that is the total of hours registered in the child entity. So if I delete a childrow from the grid the total is recalculated in a plugin. Only I have to refresh the parent page to show the new total. That works from the normal grid because I can capture the GridOnLoad event and refresh the page. But on the normal grid there is also a button "Show Associated Records" en if you click that you go to the Associated View Grid.. If I delete a child line from that grid the page cannot be refreshed because I cannot add the gridContext.addOnLoad(myFunction) to that grid.

     Annotation-2020_2D00_05_2D00_05-135819.png

  • Johao Larios Profile Picture
    Johao Larios 1,795 on at
    RE: Capturing the onLoad event of the Associated Grid View

    Hello Edwin,

    Are you able to modify that view in the UI? If I'm getting your questions correctly, there is no way to modify that directly even using JS.

    What you could do is use a webapi call to update the record that you want to update or just add a subgrid inside the form containing the view you need to manipulate and then use the gridControl for this new grid.

    regards,

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans