- 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.
推薦閱讀
- Excel函數、公式、圖表、數據處理從新手到高手
- VR、AR與MR項目開發實戰
- 商用級AIGC繪畫創作與技巧(Midjourney+Stable Diffusion)
- Hi!扁平化Photoshop扁平化用戶界面設計教程
- R Graph Cookbook
- UG NX 12.0實例寶典
- 數碼攝影后期處理秘笈:Photoshop CC專業調色(第2版)
- Joomla! Social Networking with JomSocial
- Photoshop圖形圖像處理實用教程
- Photoshop CS6實戰從入門到精通(超值版)
- 計算機圖形圖像處理Photoshop CS6項目教程
- Python Testing: Beginner's Guide
- 剪映+Vlog+Premiere短視頻制作從新手到高手
- PPT設計與制作實戰教程
- Moodle Course Conversion: Beginner's Guide