What event to listen on accordion panel change in extjs?

匆匆过客 提交于 2019-12-11 10:28:24

问题


What event to listen when a accordion panel is clicked and becomes visible? Any code example will be great help. Thanks!


回答1:


In ExtJS, Accordion is a layout which we will be using on Panel. Here is a sample example from sencha docs.(As you didn't mention version of ExtJS, I am assuming v4.0) :

Ext.create('Ext.panel.Panel', {
title: 'Accordion Layout',
width: 300,
height: 300,
layout:'accordion',
defaults: {
    // applied to each contained panel
    bodyStyle: 'padding:15px'
},
layoutConfig: {
    // layout-specific configs go here
    titleCollapse: false,
    animate: true,
    activeOnTop: true
},
items: [{
    title: 'Panel 1',
    html: 'Panel content!',
    listeners: {
        afterrender: function(thisCmp, eOpts) //(Ext.Component this, Object eOpts ) {
            // do what you want to do here
        }
    }
},{
    title: 'Panel 2',
    html: 'Panel content!'
},{
    title: 'Panel 3',
    html: 'Panel content!'
}],
renderTo: Ext.getBody()
});

All events associated with Panel are applicable here. Check out usage of these events here on sencha docs.




回答2:


expand; see:

http://docs.sencha.com/ext-js/4-0/#!/api/Ext.panel.Panel-event-expand

Here is a working code snippet of mine you could substitute for the items in the example code above, that is working for me:

items: [{
    title: 'Watch Folder',
    html: 'Watch Folder'
},{
    title: 'Saved Search',
    html: 'Saved Search',
    listeners: {
        expand: function() {
            console.log('saved-search/expand');
        }
    }
},{
    title: 'Search History',
    html: 'Search History'
},{
    title: 'Special',
    html: 'Special'
}]


来源:https://stackoverflow.com/questions/9572167/what-event-to-listen-on-accordion-panel-change-in-extjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!