A.K*_*A.K 2 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
}
Run Code Online (Sandbox Code Playgroud)
我也试过window.parent.document.getElementById,但在这两种情况下,.control都是null或未定义,最终得到:
TypeError:无法获取未定义或空引用的属性"SetParameter"
非常感谢您的帮助/提示.谢谢,
这是解决方案:
我们需要使用 window.parent.document.getElementById
等待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);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7182 次 |
| 最近记录: |