Dynamics CRM 2015 Applying custom subgrid with FetchXML (getElementById(“selectedGrid”) returns null)

独自空忆成欢 提交于 2019-12-25 04:33:39

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!