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.
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);
}
})
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.
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.