locked
Crm 2011 - Force All Tabs to Collapse RRS feed

  • Question

  • Im currently using this code:

    // ONLOAD - COLLAPSE ALL TABS
    function collapse() {
     var formtabs = Xrm.Page.ui.tabs.get();<o:p></o:p>

     for(var i in formtabs) {
      var tab =
    formtabs[i];
      var currentTabState = tab.getDisplayState();
      var newTabState = "";

      if (currentTabState == "expanded") {
         newTabState = "collapsed";
      }
      tab.setDisplayState(newTabState);

      }

    }

    Note:

    This code currently collapses all my tabs onload of the form, but 1 tab still always expands.

    Monday, August 19, 2013 5:31 AM

All replies

  • CRM is setting focus to a field in your first tab after you collapse them all, which is automatically expanding the tab again.

    You can get around this by setting a timeout before collapsing the first tab, something like this (increase the timeout if it's not long enough):

    // ONLOAD - COLLAPSE ALL TABS
    function collapse() {
     var formtabs = Xrm.Page.ui.tabs.get();<o:p></o:p>
    
     for(var i in formtabs) {
      var tab = formtabs[i];
      var currentTabState = tab.getDisplayState();
      var newTabState = "";
    
      if (currentTabState == "expanded") {
         newTabState = "collapsed";
      }
      tab.setDisplayState(newTabState);
      }
    
      setTimeout(function() {
        formtabs[0].setDisplayState("collapsed");
      }, 100);
    }

    Hope that helps

    Paul


    If my response helped you find your answer please show your thanks by taking the time to "Mark As Answer" and "Vote As Helpful".

    Twitter LinkedIn Facebook Blog Magnetism

    Monday, August 19, 2013 6:59 AM
  • Hi Paul,

    Thanks for the input. Any other work-around?

    My form contains a lot of subgrid, which will take time to load, and that will depend on the count of records loaded on each subgrid.

    Putting a time-out in collapsing the tabs surely does the job, but is there any other way to force the issue aside from 'time-out' approach? Thanks Paul.


    • Edited by point_blank Monday, August 19, 2013 11:24 AM
    Monday, August 19, 2013 11:23 AM