locked
Javascript - Trying to hide section containing a subgrid when the subgrid has no values RRS feed

  • Question

  • I have a subgrid in a section. If there are no values in the subgrid, then I want to hide the whole section.

    I'm having trouble checking if there are values in the subgrid. I think it might be something to do with the fact that subgrids load asynchronously, is that correct?? I found some code online, which I'm calling in the form onLoad:

    vs_scc_student_OnLoad= function() {
    
    // If no data in subgrid, hide it
    var test = Xrm.Page.ui.controls.get('PastSupports')._control.get_innerControl().get_allRecords();
    alert(test);
    }

    I just put in the alert to see what would come back. I don't expect there to be values in there, maybe just the object type...it's not important, I just wanted to see if anything would be returned.

    When I load my form, I get the following error:

    unable to get property 'get_allRecords' of undefined or null reference

    How do I ensure that the subgrid is fully loaded before this code is called (if that is indeed what the problem is)?

    All I need is the count of the number of records, or just to know if at least 1 is being returned. If it's 0, then I need ot hide the whole section that contains the subgrid.

    Thanks.

    Wednesday, September 25, 2013 9:08 AM

All replies