How to refresh the ribbon of the Homepage Grid in CRM 2011



  • As we know in an Entity Form of CRM 2011, if we want to refresh the ribbon to reactivate the enable rules or the display rules for example, we call the method refreshRibbon() of the object Xrm.Page.ui. But what happen if we try this method in the ribbon of the Homepage Grid of an Entity? We'll find that the Xrm.Page.ui returns null and therefore won't have the method previous mentioned. Then, what we have to do to refresh the ribbon in the Homepage Grid for example when another button in the Ribbon needs to update the rules when it is clicked?

    This method is not supported by Microsoft. Use it under your own risk.

    Is very simple. The only thing we have to do is to call the click event of the refresh button of the entity grid in our function:

    function RefreshHomeRibbon(){

          var refresh = document.getElementById("refreshButton"); // this will be the table container

          if(refresh != null) {

            refresh.children[0].children[0].children[0].children[0].onclick(); // call click event in the <a> tag

            //       <tbody>      <tr>         <td>        <a>    

            // Sometimes you need to call twice to take effect

            refresh.children[0].children[0].children[0].children[0].onclick();

              }

    }

    The refresh object will return an html table. To access the click event you need to enter the <a> tag children and call it.

    And finally call this function in yours (RibbonButtonClick here):

    function RibbonButtonClick(){

         var a = b + c;

         RefreshHomeRibbon();

    }

    Enjoy it!



  • Comments



Add a Comment