- 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.
- ColdFusion 9 Developer Tutorial
- Photoshop CC 實戰入門
- SOLIDWORKS Visualize 實例詳解(微視頻版)
- 皮膚鏡圖像分析與識別
- 中文版Photoshop CS6全能修煉圣經(移動學習版)
- CAXA 實體設計2013案例課堂
- 中文版AutoCAD 2022從入門到精通
- Python氣象應用編程
- Origin 2022科學繪圖與數據分析(高級應用篇)
- Audition CC音頻處理完全自學一本通
- 中文版3ds Max 2014基礎培訓教程
- 傳奇:ZBrush數字雕刻大師之路(第2版)
- Revit 2022中文版完全自學一本通
- SOLIDWORKS 2023中文版機械設計從入門到精通
- Photoshop CS6 中文版從入門到精通