【问题标题】:crm 2011 js - Get associated grid view on refreshcrm 2011 js - 刷新时获取关联的网格视图
【发布时间】:2016-10-28 04:48:23
【问题描述】:

我在 CRM 2011 中有一个套件报价产品,我试图在相关产品视图更新时调用一个函数。

在 F12 调试工具中,我可以看到网格 id 是 'crmGrid_productassociation_association':

但是下面的js代码好像不行:

var grid = document.getElementById("crmGrid_productassociation_association").control;
if (grid != null)
{
    alert("success");
}   

当我在页面加载时运行此代码时:

console.dir(Xrm.Page.ui.controls.get());

crmGrid_productassociation_association 控件未出现在控件列表中。相反,仅显示原始报价产品上的控件。有谁知道如何在关联的网格视图刷新时调用 js 函数?

【问题讨论】:

    标签: javascript crm microsoft-dynamics quote


    【解决方案1】:

    对于那些想知道的人,我能够在 CRM 2011 中使用 JS 获得关联的网格,您需要一个看起来像这样的函数:

    function reloadKitProducts() {
        var iframe = document.getElementById('areaKitsFrame');
    
        if (iframe == null || iframe.readyState != "complete") {
            setTimeout(reloadKitProducts, 3000);
            return;
        }
    
        var subgrid = iframe.contentWindow.document.getElementById('crmGrid_productassociation_association').control.add_onRefresh(getKitProductsOnLineItemChange);
    }
    

    您需要获取包含子网格的 iframe 的 id。这是这里的主线:

    var subgrid = iframe.contentWindow.document.getElementById('crmGrid_productassociation_association').control.add_onRefresh(getKitProductsOnLineItemChange);
    

    它只在你点击导航窗格中的链接时加载,仍然需要一两秒才能加载,所以你必须实现递归超时。

    【讨论】:

      猜你喜欢
      • 2013-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多