Development

MS CRM 2011: How to refresh Associated or SubGrid from Ribbon button

Today I have got requirement – create custom ribbon button placed to Associated View of entity, execute some logic and invoke refresh of grid. Last point was the trickiest one and that’s why I decided to share with approach how to do it.

First step is to create library that will contain JavaScript that will be executed when button is clicked:

OnRibbonButtonClicked = function(grid){
    //put your logic here

    //code that refreshes grid
    grid.refresh();
}

Second step is to customize ribbon (I use for it Ribbon Workbench). As a sample I took contact entity. Select Subgrid Option in Ribbon Workbench:

Create new button:

Create new command and configure action of created command. Key point here is to pass grid as a parameter of handler:

Click OK and define command for button:

Publish solution:

Recheck that it works:

2 Comments

  1. Great Post Andrii…
    Actually i want to create same for Opportunity form, so can u send me source code of javascript and html.
    Email.ID:riturewatkar.89@gmail.com
    Thanks,
    Ritu

    1. Hello,
      Code that I used is in the start of post. And there is no html. What is not clear for you?
      Andrew

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.