[英]How can i get the active list in a subgrid in Dynamics CRM using javascript?
What is the javascript code to get the active list which is being shown in a subgrid if the subgrid is designed to show more than one list in the Additional options with the view selector. 如果子网格设计为在视图选择器的“其他”选项中显示多个列表,则获取该子列表中正在显示的活动列表的javascript代码是什么。
What I am trying to achieve is regarding to the list that has been selected in the subgrid I want to assign a new fetchXML value in Javascript. 我想要实现的是关于要在Java脚本中分配新的fetchXML值的子网格中已选择的列表。
var grid = parent.document.getElementById("mySubGrid");
// my subgrid has more than one list so I need to get the active list
// if (activeList=="all_elements") {fetchxml=activeListXML} else
// {fetchxml=anotherXML}
grid.control.SetParameter("fetchXML", fetchXml);
Thanks in advance for your help 在此先感谢您的帮助
I noticed that you are trying to use getElementById
; 我注意到您正在尝试使用
getElementById
; this is not supported for client-side JavaScript. 客户端JavaScript不支持此功能。 Instead there is a custom API that you should use
相反,您应该使用一个自定义API
You can get a Grid Control's current view
using the following 您可以使用以下命令获取网格控件的当前
view
// Remember when configuring this webresource to enable passing Execution Context
function myCustomGridAction(executionContext)
{
// Use executionContext to retrieve FormContext
var formContext = executionContext.getFormContext();
// use the formContext to access the particular Grid
var gridContext = formContext.getControl("myGridId");
// use the gridContext to get the current View
var viewSelector = gridContext.getViewSelector();
// use the viewSelector to get the current view
var view = viewSelector.getCurrentView();
// view contains the following properties
// the View's object type code (Saved Query = 1039) or (User Query (4230)
console.log(view.entityType);
// the ID of the view
console.log(view.id);
// the Name of the view
console.log(view.name)
}
More information is here 更多信息在这里
NOTE : If the subgrid control is not configured to display the view selector, calling this method on the viewSelector object will throw an error.
注意 :如果未将子网格控件配置为显示视图选择器,则在viewSelector对象上调用此方法将引发错误。
If you want the XML that the view is using the approach is slightly different 如果您希望视图使用的XML方法稍有不同
// Remember when configuring this webresource to enable passing Execution Context
function myCustomGridAction(executionContext)
{
// Use executionContext to retrieve FormContext
var formContext = executionContext.getFormContext();
// use the formContext to access the particular Grid
var gridContext = formContext.getControl("myGridId");
// get the XML used to query records displayed in Grid
var xml = gridContext.getFetchXml();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.