我试图在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
}
I have through this and this
我也尝试了window.parent.document.getElementById
,但在这两种情况下,.control
是空的或未定义的,并以:
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);
}
}
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"。这在CRM 7.1中仍然有效吗?由于