英文:
Is there any way to Filter a Sub Grid Dynamically in Model Driven App
问题
我在表单中有一个子网格,在那里,我需要根据表的另一个字段的数据来过滤列。我一直尝试使用JavaScript来实现这一点,但不确定出现了错误"undefined"。尝试了很多方法,但没有帮助。
var conSubGrid = Xrm.Page.getControl("Subgrid_new_9");
conSubGrid.setFilterXml("<filter><condition attribute=’cr85c_Nameid’ operator=’eq’ value=’ABCD’ /></filter>");
conSubGrid.refresh();
我能够获取当前网格的详细信息,但无法设置筛选条件。
任何帮助将不胜感激,提前致谢。
英文:
I am having Sub-Grid in a Form where, I need to filter a Column as per the data from other feild of a table. I have been trying to achieve this using Java Script but not sure getting the error an "undefined". Tried out many way but nothing has helped.
var conSubGrid = Xrm.Page.getControl("Subgrid_new_9");
conSubGrid.setFilterXml("<filter><condition attribute=’cr85c_Nameid’ operator=’eq’
value=’ABCD’ /></filter>");
conSubGrid.refresh();
I am able to fetch the Current Grid Details but not able to Set the filter Criteria.
Any help will be appreciated, thanks in advance.
答案1
得分: 1
请注意,setFilterXml是subgrid的一个未记录的JavaScript API,因此将来可能会出现可能的弃用或删除。
根据其他论坛中提供的示例,您必须将整个fetchXML传递给setFilterXml,而不仅仅是filterxml。
> 更新:修改下面的函数以获取fetchXml,并修改以附加filterxml并设置FetchXml并刷新
function SubGridFilterExecution(executionContext) {
var formContext = executionContext.getFormContext();
var gridContext = formContext.getControl("Subgrid_new_9");
var fetchXml = gridContext.getFetchXml();
fetchXml = fetchXml.replace("</entity>", "<filter><condition attribute='cr85c_Nameid' operator='eq' value='ABCD' /></filter></entity>");
gridContext.setFilterXml(fetchXml);
gridContext.refresh();
}
来源链接:https://www.crmcrate.com/javascript/dynamics-365-crm-filter-the-sub-grid-dynamically-with-javascript/
英文:
Please note that setFilterXml is an undocumented javascript api for subgrid so there might be possible deprecation or removal of this api in future.
As per the samples avaialable in other forums you have to pass the whole fetchXML in the setFilterXml and not just the filterxml.
> Update: modified below function to get fetchXml and modify to append
> the filterxml and setFetchXml & Refresh
function SubGridFilterExecution(executionContext) {
var formContext = executionContext.getFormContext();
var gridContext = formContext.getControl("Subgrid_new_9");
var fetchXml = gridContext.getFetchXml();
fetchXml = fetchXml.replace("</entity>", "<filter><condition attribute='cr85c_Nameid' operator='eq' value='ABCD' /></filter></entity>");
gridContext.setFilterXml(fetchXml);
gridContext.refresh();
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论