How do I force a subpanel to be open

I am looking to force a particular subpanel, say Documents, to be open on the loading of a record.  I have found a little code but its all 6.x related.

  • This code may help you:

    ({
    extendsFrom: 'BaseSubpanelLayout',

    initialize: function(options) {
    this._super('initialize', [options]);
    },

    _render: function() {
    this._components[0].render();
    this.$('.subpanel').toggleClass('closed', false);
    }
    })

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • I see how that code works but I cant see any way to narrow it down to a particular module.

  • Hi Kenneth Brill,

    You can override subpanel layout controller and override _initPanelState function within it which comes from parent layout panel.js.

    custom/clients/base/layouts/subpanel/subpanel.js

    ({
       extendsFrom: 'SubpanelLayout',
        initialize: function(options) {
           this._super('initialize', [options]);
        },



       _initPanelState: function() {
           this._super('_initPanelState');
           //if override is available, use it (it will override user last state property)
           if(!_.isUndefined(this.options.def.override_subpanel_collapse)) {
              this.context.set('collapsed', this.options.def.override_subpanel_collapse);
           }
        }
    })

    Then, add override property to your subpanel layout metadata file. For eg:

    $viewdefs['<module_name>']['base']['layout']['subpanels'] = array(
       'components' => array(
          array(
             'layout' => 'subpanel',
             'label' => 'LBL_DOCUMENTS_SUBPANEL',
             'context' => array(
             'link' => 'documents',
          ),

          //add override property for subpanel to hide/show
          'override_subpanel_collapse' => false,
       )

    );

    This way, you can add the above override property to any subpanel you want to be expand or collapse by default irrespective of the user last state.

    Note: This would still obey the application level collapse settings (in Admin->System Settings). If checked, all subpanels will be collapsed by default.

    Let us know if this helps.

    Regards.

  • Hello Kenneth,

    here is my take on this one. I know it's some time ago but maybe could be useful to someone else!

    Note: This code should not obey the application level collapse settings (in Admin->System Settings).

    custom/clients/base/layouts/panel/panel.js

    Line 7 Subpanel module

    Line 9 Main Record module

    ({
        extendsFrom: 'PanelLayout',

        _initPanelState: function() {
          this._super('_initPanelState');

          if(this.module=='Contacts') {
            if(!_.isUndefined(this.context.attributes.parentModule)) {
              if(this.context.attributes.parentModule == 'Cases') {
                this.context.set('collapsed', true);
              }
            }
          }
        },

    })
  • Thanks Diego -- We need a developer who can integrate sugarcrm with our website

  • Hello Mily  Rose

    Can you share your requirements for Integration of your website with SugarCRM?

    You can send email to : hiren@dreamertechs.com