Crm 2011 : Refresh associated Grid View

ⅰ亾dé卋堺 提交于 2019-12-02 09:55:55

问题


Is there a way to refresh associated Grid View ? I have a Sales Order View on the Account Form, on this Form I have a button (New Order) that open a new Sales Order Form, in this form I do my Orders, The question is : When I save on my Order Form I want to refresh my Order associated View (in the Account Form) , but I don't know how to get the control name or how to access to it. I tried many ways Like

  Xrm.Page.ui.controls.get("Orders").refresh();
  document.getElementById("areaOrders").contentWindow.location.reload(true);

Thank's.


回答1:


To refresh a subgrid you can use

Xrm.Page.getControl('new_subgrid').refresh();

However in my experience it is very buggy (since RU12 anyway), so use with caution. You also need to check the type of the control you retrieve and ensure it is a grid or an error will be thrown.

However you have asked a slightly different question:

When I save on my Order Form I want to refresh my Order associated View (in the Account Form)

Which I understand to mean you have an Order form opened from an Account form and want to refresh the subgrid on the Account form.

The easy answer is no, you cannot do this in a supported way.

It may be possible but it wouldn't pretty. You'd need to get a reference to the opening window, which may be available in

window.opener

I haven't tried and am not infront of a machine to try it. But I would advise against it, the alternative is a single click to manually refresh the subgrid; it isn't a bad alternative.




回答2:


This is a javascript function I wrote to force Subgrid loading if the form contained more than 4 subgrids. I believe a recent rollup has made the purpose of the code obsolete, but it might be helpful for you to find your subgrids:

/*
By default, CRM only loads the first 4 subgrids on a form.  This will load
up all subgrids on the form, or only the number (over the default 4) if specified
*/
forceSubgridLoad: function (countOver4) {
    $(document).ready(function () {

        var links = $("a.ms-crm-List-LoadOnDemand");
        for (i = 0; i < links.length && (countOver4 == null || i < countOver4); i++) {
            links[i].click();
        }
    });
},



回答3:


I have blogged about auto-refreshing a sub-grid in Microsoft Dynamics CRM.
The solution is an unsupported customization, and basically boils down to this:

document.getElementById("crmGrid").control.refresh();

Replacing "crmGrid" with the div id of the sub-grid that is to be refreshed.

As far as I know there is no supported way to do a refresh.



来源:https://stackoverflow.com/questions/16612879/crm-2011-refresh-associated-grid-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!