由于Accordion只是应用于Panel的一种布局,因此没有专门的事件。这里通过监听子Panel的expand的事件来达到类似监听点击Panel事件的效果。
代码如下:
1 new Ext.Panel({ 2 width: 225, 3 region : 'center', 4 layout: 'accordion', 5 layoutConfig: { 6 titleCollapse: true, 7 animate: false, 8 activeOnTop: false, 9 hideCollapseTool: true 10 }, 11 items : [{ 12 iconCls : moduleSetCss, 13 id : moduleSetId, 14 title: moduleSetText, 15 items : configItemPanel, 16 listeners : { 17 'expand' : function(p) { 18 alert("expand:" + p.getId()); 19 } 20 } 21 },{ 22 iconCls : moduleSetCss2, 23 id :moduleSetId2, 24 title: moduleSetText2, 25 items : configItemPanel2, 26 listeners : { 27 'expand' : function(p) { 28 alert("expand:" + p.getId()); 29 } 30 } 31 }] 32 });
效果图:

当点击左侧按钮展开子菜单面板时,弹出提示框,说明监听成功。