问题
I am using Microsoft Dynamics CRM 2015 on-premise version.
I am applying a custom FetchXml to a subgrid using JavaScript.
The issue here is document.getElementById(“selectedGrid”) returns null.
I read articles says that this method is not supported anymore in 2015 Version.
My question: is there any alternative to this method?
回答1:
This works for me, and in fact I've been able to use document.getElementById as well. If you're adding an event or something (and hooking it to onLoad), just make sure you set a Timeout because grids get loaded in via iframes after the page itself loads, so there may be some delay. I ran the below script against a datagrid that exists on our Opportunity form (this JS was hooked to onsave), and was getting "Control Found" every time.
function test()
{
var control = Xrm.Page.getControl('grid_name');
if (control == null)
{
console.log("Control not found.");
//setTimeout(setTimeout(function() { test(); }, 3000));
}
else
{
console.log("Control found.");
}
}
来源:https://stackoverflow.com/questions/30787501/dynamics-crm-2015-applying-custom-subgrid-with-fetchxml-getelementbyid-selecte