简体   繁体   English

Dynamics CRM 2015 Online:SubGrid 的 control.SetParameter 方法不可用

[英]Dynamics CRM 2015 Online: SubGrid's control.SetParameter method is not available

I'm trying to populate a subgrid with fetchXml results in CRM 2015 online.我正在尝试在 CRM 2015 online 中使用 fetchXml 结果填充子网格。 One issue in the beginning was that document.getElementById("leadUmbrellaGrid");一开始的一个问题是document.getElementById("leadUmbrellaGrid"); returns 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

}

I have gone through this and this我已经经历了这个这个

I tried window.parent.document.getElementById as well but in both cases, the .control is null or undefined and end up with:我也试过window.parent.document.getElementById ,但在这两种情况下, .control都是 null 或 undefined 并最终得到:

TypeError: Unable to get property 'SetParameter' of undefined or null reference类型错误:无法获取未定义或空引用的属性“SetParameter”

Would appreciate your help/tips.感谢您的帮助/提示。 Thanks,谢谢,

Here's the solution:这是解决方案:

  1. We need to use window.parent.document.getElementById我们需要使用window.parent.document.getElementById

  2. Wait for the control to load in the DOM.等待control加载到 DOM 中。

So the code would look like this:所以代码看起来像这样:

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);
    }
}
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 (relatedProjectsSubGrid.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);
        }

    }

Ive tried this one but didn't quite get where did you get the "relatedProjectsSubGrid.control", also is this still working for CRM 7.1?我试过这个,但不太明白你从哪里得到“relatedProjectsSubGrid.control”,这是否仍然适用于 CRM 7.1? Thanks谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 设置子网格的fetchXML时,无法读取Dynamics CRM中未定义的属性“ SetParameter” - Cannot read property 'SetParameter' of undefined in Dynamics CRM while setting up fetchXML of a subgrid 如何在 Dynamics CRM 2015 Update 1 online 中将仪表板的宽度设置为 100% - How to set width of the dashboard to be 100% in Dynamics CRM 2015 Update 1 online FetchXML查询在子网格中返回的Dynamics CRM 2015中的活动记录-主题超链接打开新的活动 - Activity records in Dynamics CRM 2015 returned in subgrid by FetchXML query - Subject hyperlink opens new Activity 如何以Dynamics CRM形式调整子网格的高度? - How to resize the height of the subgrid in dynamics crm forms? dynamics crm在关联的视图上获取子网格的名称 - dynamics crm get name of subgrid on associated view 动态CRM。 在subgrid中完全自定义FetchXml - Dynamics CRM. Fully custom FetchXml in subgrid CRM Dynamics 2015 IFrame通信 - CRM Dynamics 2015 IFrame Communication Dynamics CRM2016:无法读取未定义的属性“ SetParameter” - Dynamics CRM2016: cannot read property 'SetParameter' of undefined 我想使用纯Javascript从MS Dynamics CRM Online 2015添加/检索数据 - I want to add/retrieve data from MS Dynamics CRM Online 2015 using pure Javascript MS Dynamics CRM 2013子网格与其添加按钮重叠 - Ms dynamics crm 2013 subgrid overlap with its add button
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM