locked
Refresh All Sub Grids Using JavaScript RRS feed

  • Question

  • Hi.

    I'm organizing forms, views and fields in MS CRM 2011 (UR5, Windows Server 2008 R2) for a Marina Company. And have a question about it.

    There are 5 tabs and total 11 subGrids in an entity form and what I need is to refresh all subGrids when tab is clicked.

    Most of the approaches guide me to use the code below;

    var element = document.getElementById("subGridName");
    element.refresh();

    But I think, this is not effective. That's why, I prefer this;

    function refreshAllSubgrids() {
        var allControls = Xrm.Page.getControl();
        if(allControls[0] == null){
            setTimeout('refreshAllSubgrids()',2000);
            return;
        }
        for(var i in allControls) {   
            if(allControls[i].getControlType()=="subgrid") {
                allControls[i].refresh();   
            }
        }
    }

    Here is the situation;

    When I use the second JS code as an event for Contact entity I get no error and lo but same function throws exception both for Account and BoatCard entities. According to my thought, this is sth with the UR5 thing. 

    I wonder if you prefer any solution or have thought about this.

    Thanks in advance.

    Can


    • Edited by cankabaklarli Wednesday, September 11, 2013 11:11 AM texting
    Wednesday, September 11, 2013 11:10 AM

All replies

  • You should stay with the supported method of using the refresh function from the client sdk. http://msdn.microsoft.com/en-us/library/gg334266.aspx

    If it is failing you would need to provide us some exception detail or try to debug using IE dev tools to see why it is failing. UR6 is the base version download now so I would not recommend writing unsupported DOM script instead of upgrading and testing on a later Rollup to rule this out.


    MS CRM Bing'd - http://bingsoft.wordpress.com
    Dynamics XRM Tools CRM 4 to CRM 2011 JavaScript Converter Tool
    CRM 2011 OData Query Designer
    CRM 2011 Metadata Browser
    CRM Forum Guidance

    Wednesday, September 11, 2013 1:33 PM
    Moderator