Javascript Extjs手风琴项目如何使打开的项目在单击时不再关闭
我想知道是否有可能不允许用户在项目打开时再次关闭它,这意味着只有在我单击手风琴中的另一个项目时才允许它关闭。 希望足够清楚 我正在添加代码:Javascript Extjs手风琴项目如何使打开的项目在单击时不再关闭,javascript,extjs,Javascript,Extjs,我想知道是否有可能不允许用户在项目打开时再次关闭它,这意味着只有在我单击手风琴中的另一个项目时才允许它关闭。 希望足够清楚 我正在添加代码: Ext.define('application.view.SystemHealth', { extend: 'Ext.Container', alias: 'widget.globalSynchronization', requires: ['infra.view.views.BoxHeader', 'application.view.System
Ext.define('application.view.SystemHealth', {
extend: 'Ext.Container',
alias: 'widget.globalSynchronization',
requires: ['infra.view.views.BoxHeader',
'application.view.SystemStatusHeader',
'application.model.SystemHealth',
'application.store.SystemHealth',
'infra.utils.pvs.SyncJobRunningStep',
'application.view.CostCalculation',
'application.view.SystemStatusHeader',
'application.view.DataCollector',
'application.view.PublicCloudConnection',
'Ext.layout.container.Accordion'
],
layout:{
type:'vbox',
align:'stretch'
},
header: false,
cls: ['global-synchronization'],
syncJobStatus: null,
initComponent: function() {
var me = this;
me.store = Ext.create('itfm.application.store.SystemHealth');
me.store.load({scope: me, callback: me.onLoadDone});
Ext.apply(me, {
items: [
{
xtype: 'boxHeader',
width: '100%',
title: itfm.application.T.GlobalSynchronizationTitle
},
{
xtype: 'label',
width: '90%',
html: itfm.application.T.GlobalSynchronizationDescription,
margin: "0 0 30 10"
}
]
});
me.callParent(arguments);
},
onLoadDone: function(records, operation, success){
var me =this;
var accordionItemsMargin = '0 0 30 0';
me.accordion = Ext.create('Ext.panel.Panel', {
margin: "0 0 30 10",
defaults:[{
layout:'fit',
height:'100%',
width:'100%'
}] ,
layout: {
type: 'accordion',
titleCollapse: false,
animate: true,
activeOnTop: true,
fill : true,
collapseFirst :true
},
items: [
{
height: 180,
xtype: 'dataCollector',
autoScroll:true,
margins: accordionItemsMargin,
store: records[0].dcModule()
}
,
{
xtype: 'costCalculation',
margins: accordionItemsMargin,
store: records[0].ccModule()
},
{
xtype: 'publicCloudConnection',
margins: accordionItemsMargin,
store: records[0].pcModule()
}
]
});
me.add( me.accordion);
}
}))
感谢您的帮助您想要的是,当用户单击当前展开的面板时,不会发生任何事情,而不是折叠和展开下一个面板,对吗 不幸的是,没有内置的选项。。。如果你真的想要它,你必须重写Ext.layout.container.Accordion并自己实现它 编辑 事实上,大多数折叠/扩展代码都位于
Ext.panel.panel
类中
这个简单的覆盖似乎足以满足您的需要。显然,此方法仅用于折叠侦听器,因此不会产生任何不利影响(除非此方法也在代码中的某个地方使用…)
请参阅。我可以用以下命令覆盖手风琴
Ext.define('itfm.application.view.SystemHealthAccordion', {
extend: 'Ext.layout.container.Accordion',
alias: ['layout.systemHealthAccordion'] ,
constructor: function() {
var me = this;
me.callParent(arguments);
},
onComponentExpand: function(comp) {
var me = this;
me.callParent(arguments);
var button = comp.down('tool');
button.setDisabled(true);
},
onComponentCollapse: function(comp) {
var me = this;
me.callParent(arguments);
var button = comp.down('tool');
button.setDisabled(false);
}
}))
在手风琴第一个项目的课堂上,需要做以下工作:
me.on('boxready', me.disableTools);
},
// disable the click on the item in case it's open
disableTools: function(){
var me = this;
var button = me.getHeader().down('tool');
button.setDisabled(true);
}
因此,当第一项打开时,它将具有相同的行为是的,这正是我要做的。。基本上,我想要的行为与下面的手风琴一样:似乎有一种简单的方法可以实现您想要的行为,请参阅我的更新。
me.on('boxready', me.disableTools);
},
// disable the click on the item in case it's open
disableTools: function(){
var me = this;
var button = me.getHeader().down('tool');
button.setDisabled(true);
}