- Ext JS 3.0 Cookbook
- Jorge Ramon
- 387字
- 2021-04-01 13:43:47
Wizard style UI using a card layout
The Wizard style UI is perfect when you need to lead the user through a series of steps in a specific sequence. Wizards are especially suited for complex or infrequently performed tasks, where the user is unfamiliar with the steps involved. In the following screenshot, you'll see what the Wizard style UI built in this recipe looks like:

How to do it...
- Create the wizard's cards or steps:
card0=new Ext.Panel({ id: 'card-0', html: '<h1>Step 1 of 3</h1><p>Welcome to the wizard. </p><p>Click the "Next" button to continue...</p>' }); card1=new Ext.Panel({ id: 'card-1', html: '<h1>Step 2 of 3</h1><p>One more step left.</p><p>Please click the "Next" button to continue...</p>' }); card2=new Ext.Panel({ id: 'card-2', html: '<h1>Step 3 of 3</h1><p>This is the last step. You made it!</p>' });
- You need a function to switch the steps:
var navigationHandler=function(increment) { var layout=Ext.getCmp('card-wizard').getLayout(); var activeItemIdx=layout.activeItem.id.split('card-')[1]; var next=parseInt(activeItemIdx) + increment; layout.setActiveItem(next); if (next==0) { Ext.getCmp('card-prev').setDisabled(true); } else { Ext.getCmp('card-prev').setDisabled(false); } if (next==2) { Ext.getCmp('card-next').setDisabled(true); } else { Ext.getCmp('card-next').setDisabled(false); } };
- Now, put the steps together in a container:
var cardWizard=new Ext.Panel({ id: 'card-wizard', title: 'A wizard using card layout', applyTo: 'card-panel', width: 400, height: 300, frame:true, layout: 'card', activeItem: 0, bodyStyle: 'padding:15px;background-color:#ffffff', defaults: { border: false }, bbar: ['->', { id: 'card-prev', text: 'Previous', handler: navigationHandler.createDelegate(this, [-1]), disabled: true, iconCls: 'btn-arrow-left-green', cls:'x-btn-text-icon', minWidth:50 }, { id: 'card-next', text: 'Next', handler: navigationHandler.createDelegate(this, [1]), iconCls: 'btn-arrow-right-green', cls: 'x-btn-text-icon', minWidth: 50, style:'text-align:left' }], items: [card0, card1, card2] });
A wizard is built by creating a number of panels that will function as wizard steps. The panels are hosted in a container that uses a CardLayout
. This layout makes each panel fit to the container with only a single panel visible at any given time.
The CardLayout
does not provide a mechanism for handling navigation from one panel to the next. Therefore, this functionality must be provided by the developer. Since only one panel is displayed at a time, the navigation handler will achieve moving from one panel to the next by calling the layout's setActiveItem
method and passing the ID or index of the next panel to display.
- Moodle 1.9 for Teaching 7/14 Year Olds: Beginner's Guide
- 對比Excel,輕松學習SQL數據分析
- 邊做邊學:Photoshop CS6 圖像制作案例教程
- SolidWorks2014基礎實例教程
- Joomla! Social Networking with JomSocial
- 專業級音樂制作理論與實踐Pro Tools:從入門到應用
- Implementing SugarCRM 5.x
- Elgg Social Networking
- UG NX 12.0完全自學寶典
- Linux Shell Scripting Cookbook
- Oracle Application Express Forms Converter
- Jasmine JavaScript Testing
- Linux Shell腳本攻略(第3版)
- Magento 1.4 Development Cookbook
- 手把手教你學成PPT高手