由於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 });
效果圖:

當點擊左側按鈕展開子菜單面板時,彈出提示框,說明監聽成功。