CRM 2011 - Refresh a grid from jscript.

Answered CRM 2011 - Refresh a grid from jscript.

  • Monday, November 14, 2011 9:46 AM
     
     

    CRM 2011.

    I have a ribbon button.  It appears on the form, on a Dashboard Grid and on a conventional Grid.

    The first one is no problem but I want to create a function that will refresh the Grid which is associated with the button so both a sub-grid and a grid and then call this after my JSON update.

    Anyone have a simple piece of JScript that will will do this.

All Replies

  • Monday, November 14, 2011 9:34 PM
     
     Answered Has Code

    Use refresh function of Xrm.Page.ui 

    following example from SDK shows how to do it for Sub-Grid

    refreshAllSubGrids: function ()
    {
        var controls = Xrm.Page.ui.controls.get(SDK.ControlSamples.isSubGrid);
    
        if (controls.length > 0)
        {
            
            var subGridNames = "";
            for (var i in controls)
            {
                controls[i].refresh();
                subGridNames += (" - "+controls[i].getName() + "\n");
            }
            alert("The following subgrids were refreshed: \n" + subGridNames);
        }
        else
        {
            alert("There are no subgrid controls on the current form.");
        }
    },
    
    isSubGrid: function (control, index)
    {
        return control.getControlType() == "subgrid";
    },
    
    



    MaKeer | myencounterwithcrm.wordpress.com | CRM2011 User Settings Utility | CRM2011 Lookup Preview | CRM2011 Lookup Attribute Mapping | CRM2011 TreeView Control (Beta)
    • Marked As Answer by Gordon Johnston Wednesday, November 16, 2011 8:32 AM
    •