- Ext JS 3.0 Cookbook
- Jorge Ramon
- 324字
- 2021-04-01 13:43:47
Stacking items with an accordion layout
Countless applications use a layout where multiple panels are positioned in an expandable accordion style, such that only one panel can be open at any given time. This recipe is a sample that tries to borrow the look of popular email applications to explain how to configure and use an accordion layout.

How to do it...
- Create the Mail panel:
panel1=new Ext.Panel({ title: 'Mail', items: [{ xtype: 'treepanel', id: 'inbox-tree', autoScroll: true, animate: true, enableDD: true, containerScroll: true, border: false, dataUrl: 'mail-folders.php', root: { nodeType: 'async', text: 'MailBox', draggable: false, id: 'mailbox' } }] });
- Create the Calendar panel:
panel2=new Ext.Panel({ title: 'Calendar', bodyStyle: 'padding:10px', items: [{ xtype: 'datepicker', style: 'border:0' }] });
- Create the Contacts panel:
panel3=new Ext.Panel({ title: 'Contacts', bodyStyle: 'padding:10px', items: [{ xtype: 'fieldset', title: 'Current View', autoHeight: true, bodyStyle: 'padding:3px', items: [ { xtype: 'radio', boxLabel: 'Address Cards', hideLabel: true, name: 'contacts-view', checked: true }, { xtype: 'radio', boxLabel: 'Phone List', hideLabel: true, name: 'contacts-view' }, { xtype: 'radio', boxLabel: 'By Category', hideLabel: true, name: 'contacts-view' }, { xtype: 'radio', boxLabel: 'By Location', hideLabel: true, name: 'contacts-view'}] }] });
- Now position the panels in a container and expand the tree's root node.
var container=new Ext.Panel({ title: 'Accordion Layout', width: 200, height: 350, applyTo: 'accordion-panel', // Displays one item at a time in a stacked layout. layout: 'accordion', items: [panel1, panel2, panel3] }); // Expand the root node of the tree. Ext.getCmp('inbox-tree').getRootNode().expand();
The trick to the stacked panels resides in specifying an AccordionLayout
for the layout configuration option of the container.
推薦閱讀
- RAW攝影后期從入門到精通:Photoshop+Lightroom雙修精解
- Learning Facebook Application Development
- SolidWorks2014基礎實例教程
- 3ds Max/MaxScript印象 腳本動畫制作基礎與應用
- Photoshop+Adobe Camera Raw+Lightroom(攝影后期照片潤飾實戰(zhàn))
- AutoCAD 2017從新手到高手
- Excel公式、函數(shù)與圖表案例實戰(zhàn)從入門到精通(視頻自學版)
- Photoshop CS6案例教程(第3版)
- Photoshop CS6中文版基礎與實例教程(第6版)
- PPT設計與制作實戰(zhàn)教程
- 中文版AutoCAD 2022從入門到精通
- Apache CXF Web Service Development
- 計算機圖形制作CorelDRAW X6項目教程
- 中文版Photoshop CC 2018基礎培訓教程(全彩版)
- Photoshop CC平面設計實戰(zhàn)從入門到精通