javascript - Dynamics CRM 2015 Online : SubGrid's control. SetParameter 方法不可用

标签 javascript dynamics-crm dynamics-crm-2015

我正在尝试使用 CRM 2015 在线的 fetchXml 结果填充子网格。一开始的一个问题是 document.getElementById("leadUmbrellaGrid"); 返回 null

function filterSubGrid() {

    var leadwithSameNameGrid = Xrm.Page.getControl("leadUmbrellaGrid").getGrid();//HAVE TRIED window.parent.document.getElementById("leadUmbrellaGrid"); //grid to filter
    var currentleadId = Xrm.Page.data.entity.getId();;
    if (leadwithSameNameGrid == null) {

        setTimeout('filterSubGrid()', 500);
        return;
    }
    //fetch xml code 
    var fetchXml = "<fetchxml goes here>";


    leadwithSameNameGrid.control.SetParameter("fetchXml", fetchXml); //set the fetch xml to the sub grid   
    leadwithSameNameGrid.control.refresh(); //refresh the sub grid using the new fetch xml

}

我已经经历了thisthis

我也尝试了 window.parent.document.getElementById 但在这两种情况下,.control 都是 null 或 undefined 并以:

类型错误:无法获取未定义或空引用的属性“SetParameter”

非常感谢您的帮助/提示。 谢谢,

最佳答案

解决方法如下:

  1. 我们需要使用window.parent.document.getElementById

  2. 等待 control 加载到 DOM 中。

所以代码看起来像这样:

function filterSubGrid() 
{

    var leadwithSameNameGrid = window.parent.document.getElementById("leadUmbrellaGrid");
    var currentleadId = Xrm.Page.data.entity.getId();;
    if (leadwithSameNameGrid == null) 
    {
        setTimeout(filterSubGrid, 500);
        return;
    }

    //fetch xml code 
    var fetchXml = "<fetchxml goes here>";
    if (leadwithSameNameGrid.control != null) 
    {
        leadwithSameNameGrid.control.SetParameter("fetchXml", fetchXml); //set the fetch xml to the sub grid   
        leadwithSameNameGrid.control.refresh(); //refresh the sub grid using the new fetch xml
    } 
    else 
    {
        setTimeout(filterSubGrid, 500);
    }
}

关于javascript - Dynamics CRM 2015 Online : SubGrid's control. SetParameter 方法不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32564310/

相关文章:

javascript - 动态crm 4.0查找字段onload()查询

javascript - 从外部工作人员向套接字集群 channel 发送消息

javascript - 铯 : display/hide Labels depending on the Zoom level

javascript - 如何获取 BrowserWindow 的 url?

C# - 如果 CRM 中存在则插入或更新

debugging - 调试时无法从 CRM 插件访问外部 SQL 数据库

authentication - Microsoft Dynamics CRM 和应用程序身份验证和授权

javascript - 如何检测 CSS flex wrap 事件

azure - Dynamics 365(通过 Azure 数据工厂)到 Azure SQL Server 之间的数据传输存在时区差异

javascript - 修改网页资源中的 HTML