[英]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:这是解决方案:
We need to use window.parent.document.getElementById
我们需要使用
window.parent.document.getElementById
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.