我有这样的代码:
function FilterCasesSubgrid() {
//var CasesSubgrid = Xrm.Page.getControl("contact").getGrid();
var CasesSubgrid = window.parent.document.getElementById("contact");
if(CasesSubgrid==null){
setTimeout(function () { FilterCasesSubgrid(); }, 2000); //if the grid hasn’t loaded run this again when it has
return;
}
var fetchXml ="<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+
"<entity name='contact'>"+
"<attribute name='fullname' />"+
"<filter type='and'>"+
"<condition attribute='fullname' operator='eq' value='s%' />"+
"</filter>"+
"</entity>"+
"</fetch>";
//Here i set the fetchxml directly to subgrid
CasesSubgrid.control.SetParameter("fetchXml", fetchXml); //set the fetch xml to the sub grid
CasesSubgrid.control.Refresh(); //refresh the sub grid using the new fetch xml
}错误:
TypeError:无法读取FilterCasesSubgrid处未定义的属性“SetParameter”
发布于 2016-06-05 12:54:41
此代码不受支持,因此您不应该期望它能够工作。使用任何直接访问DOM (即window.parent.document.getElementById)或使用MSDN SDK中未定义的函数的函数都是不受支持的,应该避免使用。
但是,假设您只需要添加一个筛选器,就可以通过设置现有的FetchXML查询来支持这样做:
var myView = {
entityType: 1039, // SavedQuery
id:"{3A282DA1-5D90-E011-95AE-00155D9CFA02}",
name: "My Custom View"
}
//Set the view using ContactsIFollow
Xrm.Page.getControl("Contacts").getViewSelector().setCurrentView(myView);发布于 2016-06-04 18:27:46
您需要等待元素和控件属性(CasesSubgrid.control)。
这里已经回答了这个问题
发布于 2017-01-17 06:16:07
以下是解决办法:
所以代码看起来是这样的:
function FilterCasesSubgrid()
{
//var CasesSubgrid = Xrm.Page.getControl("contact").getGrid();
var CasesSubgrid = window.parent.document.getElementById("contact");
if(CasesSubgrid==null)
{
setTimeout(function () { FilterCasesSubgrid(); }, 2000); //if the grid hasn’t loaded run this again when it has
return;
}
var fetchXml ="<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+
"<entity name='contact'>"+
"<attribute name='fullname' />"+
"<filter type='and'>"+
"<condition attribute='fullname' operator='eq' value='s%' />"+
"</filter>"+
"</entity>"+
"</fetch>";
//Here i set the fetchxml directly to subgrid
if(CasesSubgrid.control != null)
{
CasesSubgrid.control.SetParameter("fetchXml", fetchXml); //set the fetch xml to the sub grid
CasesSubgrid.control.Refresh(); //refresh the sub grid using the new fetch xml
}
else
{
setTimeout(CasesSubgrid, 500);
}
}
https://stackoverflow.com/questions/37622413
复制相似问题