Dynamics CRM 2015 Online:SubGrid 的 control.SetParameter 方法不可用
Dynamics CRM 2015 Online: SubGrid's control.SetParameter method is not available
我正在尝试使用 CRM 2015 在线中的 fetchXml 结果填充子网格。一开始的一个问题是 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
}
我也尝试了 window.parent.document.getElementById
,但在这两种情况下,.control
都为 null 或未定义,最终结果为:
TypeError: 无法获取未定义或空引用的 属性 'SetParameter'
感谢您的 help/tips。
谢谢,
解决方法如下:
我们需要使用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 是否仍然有效?
谢谢
我正在尝试使用 CRM 2015 在线中的 fetchXml 结果填充子网格。一开始的一个问题是 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
}
我也尝试了 window.parent.document.getElementById
,但在这两种情况下,.control
都为 null 或未定义,最终结果为:
TypeError: 无法获取未定义或空引用的 属性 'SetParameter'
感谢您的 help/tips。 谢谢,
解决方法如下:
我们需要使用
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 是否仍然有效? 谢谢