commit extjs-2.2.1
[extjs.git] / docs / output / Ext.layout.CardLayout.html
1         <div class="body-wrap">
2         <div class="top-tools">
3             <a class="inner-link" href="#Ext.layout.CardLayout-props"><img src="../resources/images/default/s.gif" class="item-icon icon-prop">Properties</a>
4             <a class="inner-link" href="#Ext.layout.CardLayout-methods"><img src="../resources/images/default/s.gif" class="item-icon icon-method">Methods</a>
5             <a class="inner-link" href="#Ext.layout.CardLayout-events"><img src="../resources/images/default/s.gif" class="item-icon icon-event">Events</a>
6                             <a class="inner-link" href="#Ext.layout.CardLayout-configs"><img src="../resources/images/default/s.gif" class="item-icon icon-config">Config Options</a>
7                         <a class="bookmark" href="../docs/?class=Ext.layout.CardLayout"><img src="../resources/images/default/s.gif" class="item-icon icon-fav">Direct Link</a>
8         </div>
9                 <div class="inheritance res-block">
10 <pre class="res-block-inner"><a ext:cls="Ext.layout.ContainerLayout" ext:member="" href="output/Ext.layout.ContainerLayout.html">ContainerLayout</a>
11   <img src="resources/elbow-end.gif"/><a ext:cls="Ext.layout.FitLayout" ext:member="" href="output/Ext.layout.FitLayout.html">FitLayout</a>
12     <img src="resources/elbow-end.gif"/>CardLayout</pre></div>
13                 <h1>Class Ext.layout.CardLayout</h1>
14         <table cellspacing="0">
15             <tr><td class="label">Package:</td><td class="hd-info">Ext.layout</td></tr>
16             <tr><td class="label">Defined In:</td><td class="hd-info"><a href="../src/CardLayout.js" target="_blank">CardLayout.js</a></td></tr>
17             <tr><td class="label">Class:</td><td class="hd-info">CardLayout</td></tr>
18                                     <tr><td class="label">Extends:</td><td class="hd-info"><a ext:cls="Ext.layout.FitLayout" ext:member="" href="output/Ext.layout.FitLayout.html">FitLayout</a></td></tr>
19                     </table>
20         <div class="description">
21             *
22 <p>This layout contains multiple panels, each fit to the container, where only a single panel can be
23 visible at any given time.  This layout style is most commonly used for wizards, tab implementations, etc.
24 This class is intended to be extended or created via the layout:'card' <a ext:cls="Ext.Container" ext:member="layout" href="output/Ext.Container.html#layout">Ext.Container.layout</a> config,
25 and should generally not need to be created directly via the new keyword.</p>
26 <p>The CardLayout's focal method is <a ext:cls="Ext.layout.CardLayout" ext:member="setActiveItem" href="output/Ext.layout.CardLayout.html#setActiveItem">setActiveItem</a>.  Since only one panel is displayed at a time,
27 the only way to move from one panel to the next is by calling setActiveItem, passing the id or index of
28 the next panel to display.  The layout itself does not provide a mechanism for handling this navigation,
29 so that functionality must be provided by the developer.</p>
30 <p>In the following example, a simplistic wizard setup is demonstrated.  A button bar is added
31 to the footer of the containing panel to provide navigation buttons.  The buttons will be handled by a
32 common navigation routine -- for this example, the implementation of that routine has been ommitted since
33 it can be any type of custom logic.  Note that other uses of a CardLayout (like a tab control) would require a
34 completely different implementation.  For serious implementations, a better approach would be to extend
35 CardLayout to provide the custom functionality needed.  Example usage:</p>
36 <pre><code>var navHandler = <b>function</b>(direction){
37     <i>// This routine could contain business logic required to manage the navigation steps.</i>
38     <i>// It would call setActiveItem as needed, manage navigation button state, handle any</i>
39     <i>// branching logic that might be required, handle alternate actions like cancellation</i>
40     <i>// or finalization, etc.  A complete wizard implementation could get pretty</i>
41     <i>// sophisticated depending on the complexity required, and should probably be</i>
42     <i>// done as a subclass of CardLayout <b>in</b> a real-world implementation.</i>
43 };
44
45 <b>var</b> card = <b>new</b> Ext.Panel({
46     title: <em>'Example Wizard'</em>,
47     layout:<em>'card'</em>,
48     activeItem: 0, <i>// make sure the active item is set on the container config!</i>
49     bodyStyle: <em>'padding:15px'</em>,
50     defaults: {
51         <i>// applied to each contained panel</i>
52         border:false
53     },
54     <i>// just an example of one possible navigation scheme, using buttons</i>
55     bbar: [
56         {
57             id: <em>'move-prev'</em>,
58             text: <em>'Back'</em>,
59             handler: navHandler.createDelegate(<b>this</b>, [-1]),
60             disabled: true
61         },
62         <em>'->'</em>, <i>// greedy spacer so that the buttons are aligned to each side</i>
63         {
64             id: <em>'move-next'</em>,
65             text: <em>'Next'</em>,
66             handler: navHandler.createDelegate(<b>this</b>, [1])
67         }
68     ],
69     <i>// the panels (or <em>"cards"</em>) within the layout</i>
70     items: [{
71         id: <em>'card-0'</em>,
72         html: <em>'&lt;h1&gt;Welcome to the Wizard!&lt;/h1&gt;&lt;p&gt;Step 1 of 3&lt;/p&gt;'</em>
73     },{
74         id: <em>'card-1'</em>,
75         html: <em>'&lt;p&gt;Step 2 of 3&lt;/p&gt;'</em>
76     },{
77         id: <em>'card-2'</em>,
78         html: <em>'&lt;h1&gt;Congratulations!&lt;/h1&gt;&lt;p&gt;Step 3 of 3 - Complete&lt;/p&gt;'</em>
79     }]
80 });</code></pre>        </div>
81         
82         <div class="hr"></div>
83                 <a id="Ext.layout.CardLayout-configs"></a>
84         <h2>Config Options</h2>
85         <table cellspacing="0" class="member-table">
86             <tr>
87                 <th class="sig-header" colspan="2">Config Options</th>
88                 <th class="msource-header">Defined By</th>
89             </tr>
90                 <tr class="config-row expandable">\r
91         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
92         <td class="sig">\r
93         <a id="Ext.layout.CardLayout-deferredRender"></a>\r
94             <b>deferredRender</b> : Boolean            <div class="mdesc">\r
95                         <div class="short">True to render each contained item at the time it becomes active, false to render all contained items as soon as the ...</div>\r
96             <div class="long">\r
97                 True to render each contained item at the time it becomes active, false to render all contained items as soon as the layout is rendered (defaults to false). If there is a significant amount of content or a lot of heavy controls being rendered into panels that are not displayed by default, setting this to true might improve performance.            </div>\r
98                         </div>\r
99         </td>\r
100         <td class="msource">CardLayout</td>\r
101     </tr>\r
102         <tr class="config-row inherited alt expandable">\r
103         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
104         <td class="sig">\r
105         <a id="Ext.layout.CardLayout-extraCls"></a>\r
106             <b>extraCls</b> : String            <div class="mdesc">\r
107                         <div class="short">An optional extra CSS class that will be added to the container (defaults to ''). This can be useful for adding custo...</div>\r
108             <div class="long">\r
109                 An optional extra CSS class that will be added to the container (defaults to ''). This can be useful for adding customized styles to the container or any of its children using standard CSS rules.            </div>\r
110                         </div>\r
111         </td>\r
112         <td class="msource"><a ext:cls="Ext.layout.ContainerLayout" ext:member="#extraCls" href="output/Ext.layout.ContainerLayout.html#extraCls">ContainerLayout</a></td>\r
113     </tr>\r
114         <tr class="config-row inherited">\r
115         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
116         <td class="sig">\r
117         <a id="Ext.layout.CardLayout-renderHidden"></a>\r
118             <b>renderHidden</b> : Boolean            <div class="mdesc">\r
119                             True to hide each contained item on render (defaults to false).                        </div>\r
120         </td>\r
121         <td class="msource"><a ext:cls="Ext.layout.ContainerLayout" ext:member="#renderHidden" href="output/Ext.layout.ContainerLayout.html#renderHidden">ContainerLayout</a></td>\r
122     </tr>\r
123             </table>
124                 <a id="Ext.layout.CardLayout-props"></a>
125         <h2>Public Properties</h2>
126                 <table cellspacing="0" class="member-table">
127             <tr>
128                 <th class="sig-header" colspan="2">Property</th>
129                 <th class="msource-header">Defined By</th>
130             </tr>
131                 <tr class="property-row inherited expandable">\r
132         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
133         <td class="sig">\r
134         <a id="Ext.layout.CardLayout-activeItem"></a>\r
135             <b>activeItem</b> : Ext.Component            <div class="mdesc">\r
136                         <div class="short">
137 A reference to the Ext.Component that is active.  For example,
138 if(myPanel.layout.activeItem.id == 'item-1') { ... }....</div>\r
139             <div class="long">\r
140                 
141 A reference to the <a ext:cls="Ext.Component" href="output/Ext.Component.html">Ext.Component</a> that is active.  For example,
142 if(myPanel.layout.activeItem.id == 'item-1') { ... }.  activeItem only applies to layout styles that can
143 display items one at a time (like <a ext:cls="Ext.layout.Accordion" href="output/Ext.layout.Accordion.html">Ext.layout.Accordion</a>, <a ext:cls="Ext.layout.CardLayout" href="output/Ext.layout.CardLayout.html">Ext.layout.CardLayout</a>
144 and <a ext:cls="Ext.layout.FitLayout" href="output/Ext.layout.FitLayout.html">Ext.layout.FitLayout</a>).  Read-only.  Related to <a ext:cls="Ext.Container" ext:member="activeItem" href="output/Ext.Container.html#activeItem">Ext.Container.activeItem</a>.            </div>\r
145                         </div>\r
146         </td>\r
147         <td class="msource"><a ext:cls="Ext.layout.ContainerLayout" ext:member="#activeItem" href="output/Ext.layout.ContainerLayout.html#activeItem">ContainerLayout</a></td>\r
148     </tr>\r
149             </table>
150                 <a id="Ext.layout.CardLayout-methods"></a>
151         <h2>Public Methods</h2>
152                 <table cellspacing="0" class="member-table">
153             <tr>
154                 <th class="sig-header" colspan="2">Method</th>
155                 <th class="msource-header">Defined By</th>
156             </tr>
157                 <tr class="method-row expandable">\r
158         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
159         <td class="sig">\r
160         <a id="Ext.layout.CardLayout-setActiveItem"></a>\r
161             <b>setActiveItem</b>(&nbsp;<code>String/Number item</code>&nbsp;) : void            <div class="mdesc">\r
162                         <div class="short">Sets the active (visible) item in the layout.</div>\r
163             <div class="long">\r
164                 Sets the active (visible) item in the layout.    <div class="mdetail-params">\r
165         <strong>Parameters:</strong>\r
166         <ul><li><code>item</code> : String/Number<div class="sub-desc">The string component id or numeric index of the item to activate</div></li>        </ul>\r
167         <strong>Returns:</strong>\r
168         <ul>\r
169             <li><code>void</code></li>\r
170         </ul>\r
171     </div>\r
172                 </div>\r
173                         </div>\r
174         </td>\r
175         <td class="msource">CardLayout</td>\r
176     </tr>\r
177             </table>
178                 <a id="Ext.layout.CardLayout-events"></a>
179         <h2>Public Events</h2>
180         <div class="no-members">This class has no public events.</div>
181         </div>