[英]Cannot read property 'SetParameter' of undefined in Dynamics CRM while setting up fetchXML of a subgrid
[英]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”
感谢您的帮助/提示。 谢谢,
这是解决方案:
我们需要使用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);
}
}
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.