簡體   English   中英

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

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

我正在嘗試在 CRM 2015 online 中使用 fetchXml 結果填充子網格。 一開始的一個問題是document.getElementById("leadUmbrellaGrid"); 返回空值

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

}

我已經經歷了這個這個

我也試過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);
    }
}
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);
        }

    }

我試過這個,但不太明白你從哪里得到“relatedProjectsSubGrid.control”,這是否仍然適用於 CRM 7.1? 謝謝

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM