locked
refresh subgrid using javascript, ms crm 2011 RRS feed

  • Question

  • hi,

    i have a QuoteProduct sub grid in Quote entity.

    On click of custom button, is it possible to refresh Quote Products sub grid ?


    Thanks and Regards. Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Thursday, March 7, 2013 6:35 AM

Answers

  • This is an example from the SDK:

    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";
    },


    If the answer helped you, remember to mark it as answer.

    Thursday, March 7, 2013 6:41 AM
    Moderator

All replies

  • This is an example from the SDK:

    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";
    },


    If the answer helped you, remember to mark it as answer.

    Thursday, March 7, 2013 6:41 AM
    Moderator
  • http://social.microsoft.com/Forums/eu/crmdevelopment/thread/7293f075-daf0-4873-b30d-422d36013c9e

    http://crmdm.blogspot.in/2011/12/how-to-refresh-sub-grid-in-crm-2011.html

    try this!!


    ms crm

    Thursday, March 7, 2013 7:30 AM
  • hi

     function refresh()

    {

       var targetgird=Xrm.Page.ui.controls.get("target_grid");

         targetgrid.refresh();

    }

     once try this.

    
    
    Monday, March 11, 2013 12:13 PM
  • Hi CRMIG,

    Yes You can refresh the SubGrid whenever you click the Custom Button.

    What you have to do is .

    1.Create a javascript web resource with the following code.

    function subgridrefresh()

    {

    Xrm.Page.ui.controls.get("Subgrid Name").refresh();

    }

    2. Next you can call this javascript to your Custom Button.

    • Proposed as answer by Samba88 Tuesday, March 12, 2013 6:53 AM
    Tuesday, March 12, 2013 6:52 AM
  • Hi,

    Refer below link where almost all javascript methods are shwon:

    http://hodgin.ca/category/microsoft/dynamics-crm2011/jscript/

    http://msdn.microsoft.com/en-us/library/gg334266.aspx#BKMK_refresh

    SDK.ControlSamples.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.");
    }
    };

    SDK.ControlSamples.isSubGrid = function (control, index) {
    return control.getControlType() == "subgrid";
    };


    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Thanks and Regards, Yogesh Vijay Mulay

    Thursday, March 14, 2013 10:48 AM
  • Hi All,

    I am getting below error,

    ---------------------------
    Message from webpage
    ---------------------------
    There was an error with this field's customized event.

    Field:window

    Event:onload

    Error:'this._control.get_innerControl()' is null or not an object
    ---------------------------
    OK  
    ---------------------------

    Any solution/help for above error would be appreciated

    Thanks & Regards,
    Priyank Jain


    Wednesday, August 7, 2013 6:41 AM