简体   繁体   English

Extjs手风琴项目如何点击它时如何使一个打开的项目不再关闭

[英]Extjs accordion items how can i make an open item not to close again when clicking on it

I was wondering if it's possible to not to allow the user to close the item again when it's open, meaning to let it close only when i click on another item in the accordion. 我想知道是否有可能不允许用户在打开时再次关闭该项目,这意味着只有当我点击手风琴中的另一个项目时才让它关闭。 hope it's clear enough. 希望它足够清楚。

I'm adding the code: 我正在添加代码:

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

}

}); });

thanks for the help 谢谢您的帮助

What you want is that nothing happens when the user click on the currently expanded panel, instead of collapsing and expanding the next one, is that right? 你想要的是当用户点击当前展开的面板而不是折叠和展开下一个面板时没有任何反应,是吗?

Unfortunately, there's no built-in option for that... If you really want it, you'll have to override Ext.layout.container.Accordion and implement it yourself. 不幸的是,没有内置的选项...如果你真的想要它,你将不得不重写Ext.layout.container.Accordion并自己实现它。

Edit 编辑

In fact most of the collapsing/expanding code lies in the Ext.panel.Panel class. 事实上,大多数折叠/扩展代码都在Ext.panel.Panel类中。

This simple override seems to be enough to do what you want. 这个简单的覆盖似乎足以做你想要的。 Apparently this method is used only for collapse listeners, so it shouldn't have any adverse effect (unless the method is also used somewhere in your code...). 显然,此方法仅用于崩溃侦听器,因此不应产生任何不利影响(除非该方法也在代码中的某处使用...)。

Ext.define('Ext.ux.Panel.JQueryStyleAccordion', {
    override: 'Ext.panel.Panel'
    ,toggleCollapse: function() {
        if (this.collapsed || this.floatedFromCollapse) {
            this.callParent();
        }
    }
});

See this fiddle . 看到这个小提琴

I was able to override the accordion with the following 我能够用以下方法覆盖手风琴

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

}); });

inside the class of the first item of the accordion, there is a need to do the following: 在手风琴第一项的课程内,需要做以下事情:

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

so when the first item is open it will have the same behaviour 因此,当第一个项目打开时,它将具有相同的行为

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM