Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

JavaScript leaving white spaces

Posted on by

Hi All,

I have a Java-Script hiding 5 sub grids based on selection of a field. This is leaving white spaces when the code executes and sub-grid is hidden

function displaySubgrids() {

var AType = Xrm.Page.getAttribute("ad_type").getValue();

switch (AType) {

case 1 :

     Xrm.Page.getControl("Care").setVisible(true);

     Xrm.Page.getControl("Children").setVisible(false);

     Xrm.Page.getControl("imca").setVisible(false);

     break;

case 2 :

     Xrm.Page.getControl("Care").setVisible(false);

     Xrm.Page.getControl("Children").setVisible(true);

     Xrm.Page.getControl("imca").setVisible(false);

     break;

case 3 :

     Xrm.Page.getControl("Care").setVisible(false);

     Xrm.Page.getControl("Children").setVisible(false);

     Xrm.Page.getControl("imca").setVisible(true); 

     break;

default:

     Xrm.Page.getControl("Care").setVisible(false);

     Xrm.Page.getControl("Children").setVisible(false);

     Xrm.Page.getControl("imca").setVisible(false);

  }

}

Empty-SubGrid.PNG

The second problem is that the grids are loading with white spaces

Thanks,

*This post is locked for comments

  • Verified answer
    Michel van den Brink Profile Picture
    Michel van den Brink 4,697 on at
    RE: JavaScript leaving white spaces

    Hello,

    I recommend you place each subgrid in it's own section.

    Then instead of changing the visibility of the subgrid itself, change it on the section. Sections collapse more graceful than subgrids.

      

    See this article on interacting with sections:

    https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/formcontext-ui-sections 

    Example:

    var myTab = Xrm.Page.ui.tabs.get('tabname');
    var mySection = myTab.sections.get('sectionname');
    
    mySection.setVisible(false);

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans