locked
CRM 2011 - subgrids not included in Xrm.Page.ui.controls collection RRS feed

  • Question

  • I have a form with 5 subgrids named grdOne, grdTwo, grdThree, ...  When using the Xrm.Page.getControl(#GRID ID#) method some of the grids are not found.  Additionally, when looking at the controls in collection of Xrm.Page.ui.controls some of the subgrids are not included.  This started happening after applying Roll Up 1 and I would like to know if anyone else is experiencing this issue and if so what actions they are taking to address it.

    Wednesday, June 1, 2011 3:56 PM

Answers

All replies

  • Hi,

    You should use Xrm.Page.ui.controls.get("#GRID ID#") instead of Xrm.Page.getControl(#GRID ID#)


    Thank You,
    Jehanzeb Javeed,
    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile



    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    • Proposed as answer by Jehanzeb.Javeed Wednesday, June 1, 2011 4:52 PM
    • Unproposed as answer by Eric.W.Cahoon Wednesday, June 1, 2011 5:12 PM
    Wednesday, June 1, 2011 4:50 PM
  • document.getElementById works just fine. And if you want the CRM composite control extensions, you can use the ".control" property.

    (e.g. document.getElementById("GridName").control.refresh())

    See thread http://social.microsoft.com/Forums/en-US/crmdevelopment/thread/a7e07a1f-966b-4533-b1d3-534dd08e4b4b

     

    hope it helps...


    • Edited by Can Bilgin Wednesday, June 1, 2011 4:53 PM Typo
    Wednesday, June 1, 2011 4:53 PM
  • Thank you Jehanzeb but Xrm.Page.getControl is an allias for Xrm.page.ui.controls.get and it returns a value of null.  This is because not all of the subgrids are included in the Xrm.Page.ui.controls collection. 

    Wednesday, June 1, 2011 4:55 PM
  • Can,

    While the .control property of document.getElementById does include all of the base methods used by the Xrm.Page.ui.controls name space it does not expose the valid method names in the Xrm namespace. 

    For example document.getElementById(#GRID ID#).control contains methods for

     

    get_ControlType() which is the base method Xrm.Page.ui.controls.get(#GRID ID#).getControlType() references

    get_Visible() which is the base method Xrm.Page.ui.controls.get(#GRID ID#).getVisible() references

     

    This is an issue as Microsoft may and has changed base method signatures throughout the history of CRM.  When this happens I have to invest resources into debugging an issue just to find out that MS changed a method which they told me not to use or never intended for me to directly reference. Additionally, this is a concern because it is not possible to write something like

    Xrm.Page.ui.controls.forEach(function(control, index) { if (control.getControlType() == "subgrid") { control.refresh(); } });

    and get all of the subgrids on a form to refresh as some of the subgrids may be missing from the Xrm.Page.ui.controls collection. 

    I should have phrased by question better by asking what users have done that is supported to address this issue.  Additionally, I would like to know why some subgrids do not get included in the Xrm.Page.ui.controls collection.

    Wednesday, June 1, 2011 5:12 PM
  • Hi Eric, I am aware this is a workaround, but the issue seems to be a problem with Rollup 1, thats why I refered to you to the other thread which focuses on this issue.
    Wednesday, June 1, 2011 6:19 PM
  • Hi,

    This issue has been resolved in CRM 2011 Update Rollup 2 "Fixed: The client API cannot access subgrids in Microsoft Dynamics CRM 2011." http://support.microsoft.com/kb/2466086

    I hope your question is answered.


    Thank You,
    Jehanzeb Javeed,
    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile



    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Thursday, June 2, 2011 8:42 PM
  • Having a Similar issue, but not quite the same.  Maybe it is, I dunno.

    I can't update a subgrid from a web resource .js library.

     

    Xrm.Page.ui.controls...   returns null

    document.getElementById("idname").control.  also returns null.

     

    I have UR 2 deployed.  Ideas?



    Thursday, June 23, 2011 10:28 PM
  • Hi RC,

    If document.getElementById("idname") returns null you most likely have not set the 'name' of the grid on the form editor.  You will need to go to the form editor and verify that the name field of the sub-grid is set to value you provide. 

    Thursday, June 23, 2011 10:47 PM