I am using Extjs 6.5.3.
I want to create custom layout or a config, so that when I use that in my file all the panels will become collapsible.
I know ExtJS has Accordion layout by using which we can make all panels collapsible but accordion layout is having issue for multiple panels open at the same time even we add multi: true
config for the same. It will not allow to expand and close multiple panels at the same time.
Below is the example of not allowing multiple panels to open at same time even added multi:true
Ext.create('Ext.panel.Panel', {
title: 'Accordion Layout',
width: 300,
height: 300,
defaults: {
// applied to each contained panel
bodyStyle: 'padding:15px'
},
layout: {
// layout-specific configs go here
type: 'accordion',
titleCollapse: false,
animate: true,
multi: true,
activeOnTop: true
},
items: [{
title: 'Panel 1',
html: 'Panel content!'
}, {
title: 'Panel 2',
html: 'Panel content!'
}, {
title: 'Panel 3',
html: 'Panel content!'
}],
renderTo: Ext.getBody()
});
I also know that by using vbox layout we can make panels collapsible like below
Ext.create('Ext.panel.Panel', {
title: 'Accordion Layout',
width: 300,
height: 300,
defaults: {
// applied to each contained panel
bodyStyle: 'padding:15px',
collapsible: true
},
layout: {
// layout-specific configs go here
type: 'vbox'
},
items: [{
title: 'Panel 1',
html: 'Panel content!'
}, {
title: 'Panel 2',
html: 'Panel content!'
}, {
title: 'Panel 3',
html: 'Panel content!'
}],
renderTo: Ext.getBody()
});
But I want to have it as config or custom layout, so that I can reuse it in any place. To do this I am not finding any way.
For this you can easily implement using
Accordion
layout. You need to override accordion layoutonBeforeComponentCollapse
method by usingExt.override
.In source file exiting
onBeforeComponentCollapse
method they takingnext()
orprev()
to expanding at-least one component. You just need to add one custom configatleastOneExpanded:false
like thisAnd in
Ext.override
you need check this conditionFIDDLE
In above fiddle I have created a demo using
Ext.override
.CODE SNIPPET