Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / examples / layout-browser / layout-browser.html
1 <html>\r
2 <head>\r
3     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\r
4     <title>ExtJS Layout Examples</title>\r
5 \r
6     <!-- ** CSS ** -->\r
7     <!-- base library -->\r
8     <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />\r
9 \r
10     <!-- overrides to base library -->\r
11     <link rel="stylesheet" type="text/css" href="../ux/css/CenterLayout.css" />\r
12 \r
13     <!-- page specific -->\r
14     <link rel="stylesheet" type="text/css" href="layout-browser.css">\r
15 \r
16     <!-- ** Javascript ** -->\r
17     <!-- ExtJS library: base/adapter -->\r
18     <script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>\r
19 \r
20     <!-- ExtJS library: all widgets -->\r
21     <script type="text/javascript" src="../../ext-all.js"></script>\r
22 \r
23     <!-- overrides to base library -->\r
24 \r
25     <!-- extensions -->\r
26     <script type="text/javascript" src="../ux/CenterLayout.js"></script>\r
27     <script type="text/javascript" src="../ux/RowLayout.js"></script>\r
28 \r
29     <!-- page specific -->\r
30     <script type="text/javascript" src="layouts/basic.js"></script>\r
31     <script type="text/javascript" src="layouts/custom.js"></script>\r
32     <script type="text/javascript" src="layouts/combination.js"></script>\r
33     <script type="text/javascript" src="layout-browser.js"></script>\r
34 \r
35 </head>\r
36 <body>\r
37     <div id="header"><h1>Ext Layout Browser</h1></div>\r
38     <div style="display:none;">\r
39 \r
40         <!-- Start page content -->\r
41         <div id="start-div">\r
42             <div style="float:left;" ><img src="images/layout-icon.gif" /></div>\r
43             <div style="margin-left:100px;">\r
44                 <h2>Welcome!</h2>\r
45                 <p>There are many sample layouts to choose from that should give you a good head start in building your own\r
46                 application layout.  Just like the combination examples, you can mix and match most layouts as\r
47                 needed, so don't be afraid to experiment!</p>\r
48                 <p>Select a layout from the tree to the left to begin.</p>\r
49             </div>\r
50         </div>\r
51 \r
52         <!-- Basic layouts -->\r
53         <div id="absolute-details">\r
54             <h2>Ext.layout.AbsoluteLayout</h2>\r
55             <p>This is a simple layout style that allows you to position items within a container using\r
56             CSS-style absolute positioning via XY coordinates.</p>\r
57             <p><b>Sample Config:</b></p>\r
58             <pre><code>\r
59 layout: 'absolute',\r
60 items:[{\r
61     title: 'Panel 1',\r
62     x: 50,\r
63     y: 50,\r
64     html: 'Positioned at x:50, y:50'\r
65 }]\r
66             </code></pre>\r
67             <p><a href="http://extjs.com/deploy/dev/docs/?class=Ext.layout.AbsoluteLayout" target="_blank">API Reference</a></p>\r
68         </div>\r
69         <div id="accordion-details">\r
70             <h2>Ext.layout.Accordion</h2>\r
71             <p>Displays one panel at a time in a stacked layout.  No special config properties are required other\r
72             than the layout &mdash; all panels added to the container will be converted to accordion panels.</p>\r
73             <p><b>Sample Config:</b></p>\r
74             <pre><code>\r
75 layout: 'accordion',\r
76 items:[{\r
77     title: 'Panel 1',\r
78     html: 'Content'\r
79 },{\r
80     title: 'Panel 2',\r
81     id: 'panel2',\r
82     html: 'Content'\r
83 }]\r
84             </code></pre>\r
85             <p>You can easily customize individual accordion panels by adding styles scoped to the panel by class or id.\r
86             For example, to style the panel with id 'panel2' above you could add rules like this:</p>\r
87             <pre><code>\r
88 #panel2 .x-panel-body {\r
89     background:#ffe;\r
90     color:#15428B;\r
91 }\r
92 #panel2 .x-panel-header-text {\r
93     color:#555;\r
94 }\r
95             </code></pre>\r
96             <p><a href="http://extjs.com/deploy/dev/docs/?class=Ext.layout.Accordion" target="_blank">API Reference</a></p>\r
97         </div>\r
98         <div id="anchor-details">\r
99             <h2>Ext.layout.AnchorLayout</h2>\r
100             <p>Provides anchoring of contained items to the container's edges.  This type of layout is most commonly\r
101             seen within FormPanels (or any container with a FormLayout) where fields are sized relative to the\r
102             container without hard-coding their dimensions.</p>\r
103             <p>In this example, panels are anchored for example purposes so that you can easily see the effect.\r
104             If you resize the browser window, the anchored panels will automatically resize to maintain the\r
105             same relative dimensions.</p>\r
106             <p><b>Sample Config:</b></p>\r
107             <pre><code>\r
108 layout: 'anchor',\r
109 items: [{\r
110     title: 'Panel 1',\r
111     height: 100,\r
112     anchor: '50%'\r
113 },{\r
114     title: 'Panel 2',\r
115     height: 100,\r
116     anchor: '-100'\r
117 },{\r
118     title: 'Panel 3',\r
119     anchor: '-10, -262'\r
120 }]\r
121             </code></pre>\r
122             <p><a href="http://extjs.com/deploy/dev/docs/?class=Ext.layout.AnchorLayout" target="_blank">API Reference</a></p>\r
123         </div>\r
124         <div id="border-details">\r
125             <h2>Ext.layout.BorderLayout</h2>\r
126             <p>This Layout Browser page is already a border layout, and this example shows a separate border layout\r
127             nested within a region of the page's border layout.  Border layouts can be nested with just about any\r
128             level of complexity that you might need.</p>\r
129             <p>Every border layout <b>must</b> at least have a center region.  All other regions are optional.</p>\r
130             <p><b>Sample Config:</b></p>\r
131             <pre><code>\r
132 layout:'border',\r
133 defaults: {\r
134     collapsible: true,\r
135     split: true,\r
136     bodyStyle: 'padding:15px'\r
137 },\r
138 items: [{\r
139     title: 'Footer',\r
140     region: 'south',\r
141     height: 150,\r
142     minSize: 75,\r
143     maxSize: 250,\r
144     cmargins: '5 0 0 0'\r
145 },{\r
146     title: 'Navigation',\r
147     region:'west',\r
148     margins: '5 0 0 0',\r
149     cmargins: '5 5 0 0',\r
150     width: 175,\r
151     minSize: 100,\r
152     maxSize: 250\r
153 },{\r
154     title: 'Main Content',\r
155     collapsible: false,\r
156     region:'center',\r
157     margins: '5 0 0 0'\r
158 }]\r
159             </code></pre>\r
160             <p><a href="http://extjs.com/deploy/dev/docs/?class=Ext.layout.BorderLayout" target="_blank">API Reference</a></p>\r
161         </div>\r
162         <div id="card-tabs-details">\r
163             <h2>Ext.layout.CardLayout (TabPanel)</h2>\r
164             <p>The TabPanel component is an excellent example of a sophisticated card layout.  Each tab is just\r
165             a panel managed by the card layout such that only one is visible at a time.  In this case, configuration\r
166             is simple since we aren't actually building a card layout from scratch.  Don't forget to set the\r
167             activeItem config in order to default to the tab that should display first.</p>\r
168             <p><b>Sample Config:</b></p>\r
169             <pre><code>\r
170 xtype: 'tabpanel',\r
171 activeItem: 0, // index or id\r
172 items:[{\r
173     title: 'Tab 1',\r
174     html: 'This is tab 1 content.'\r
175 },{\r
176     title: 'Tab 2',\r
177     html: 'This is tab 2 content.'\r
178 },{\r
179     title: 'Tab 3',\r
180     html: 'This is tab 3 content.'\r
181 }]\r
182             </code></pre>\r
183             <p><a href="http://extjs.com/deploy/dev/docs/?class=Ext.layout.CardLayout" target="_blank">CardLayout API Reference</a></p>\r
184             <p><a href="http://extjs.com/deploy/dev/docs/?class=Ext.TabPanel" target="_blank">TabPanel API Reference</a></p>\r
185         </div>\r
186         <div id="card-wizard-details">\r
187             <h2>Ext.layout.CardLayout (Wizard)</h2>\r
188             <p>You can use a CardLayout to create your own custom wizard-style screen.  The layout is a standard\r
189             CardLayout with a Toolbar at the bottom, and the developer must supply the navigation function\r
190             that implements the wizard's business logic (see the code in basic.js for details).</p>\r
191             <p><b>Sample Config:</b></p>\r
192             <pre><code>\r
193 layout:'card',\r
194 activeItem: 0, // index or id\r
195 bbar: ['->', {\r
196     id: 'card-prev',\r
197     text: '&amp;laquo; Previous'\r
198 },{\r
199     id: 'card-next',\r
200     text: 'Next &amp;raquo;'\r
201 }],\r
202 items: [{\r
203     id: 'card-0',\r
204     html: 'Step 1'\r
205 },{\r
206     id: 'card-1',\r
207     html: 'Step 2'\r
208 },{\r
209     id: 'card-2',\r
210     html: 'Step 3'\r
211 }]\r
212             </code></pre>\r
213             <p><a href="http://extjs.com/deploy/dev/docs/?class=Ext.layout.CardLayout" target="_blank">API Reference</a></p>\r
214         </div>\r
215         <div id="column-details">\r
216             <h2>Ext.layout.ColumnLayout</h2>\r
217             <p>This is a useful layout style when you need multiple columns that can have varying content height.\r
218             Any fixed-width column widths are calculated first, then any percentage-width columns specified using\r
219             the <tt>columnWidth</tt> config will be calculated based on remaining container width.  Percentages\r
220             should add up to 1 (100%) in order to fill the container.</p>\r
221             <p><b>Sample Config:</b></p>\r
222             <pre><code>\r
223 layout:'column',\r
224 items: [{\r
225     title: 'Width = 25%',\r
226     columnWidth: .25,\r
227     html: 'Content'\r
228 },{\r
229     title: 'Width = 75%',\r
230     columnWidth: .75,\r
231     html: 'Content'\r
232 },{\r
233     title: 'Width = 250px',\r
234     width: 250,\r
235     html: 'Content'\r
236 }]\r
237             </code></pre>\r
238             <p><a href="http://extjs.com/deploy/dev/docs/?class=Ext.layout.ColumnLayout" target="_blank">API Reference</a></p>\r
239         </div>\r
240         <div id="fit-details">\r
241             <h2>Ext.layout.FitLayout</h2>\r
242             <p>A very simple layout that simply fills the container with a single panel.  This is usually the best default\r
243             layout choice when you have no other specific layout requirements.</p>\r
244             <p><b>Sample Config:</b></p>\r
245             <pre><code>\r
246 layout:'fit',\r
247 items: {\r
248     title: 'Fit Panel',\r
249     html: 'Content',\r
250     border: false\r
251 }\r
252             </code></pre>\r
253             <p><a href="http://extjs.com/deploy/dev/docs/?class=Ext.layout.FitLayout" target="_blank">API Reference</a></p>\r
254         </div>\r
255         <div id="form-details">\r
256             <h2>Ext.layout.FormLayout</h2>\r
257             <p>FormLayout has specific logic to deal with form fields, labels, etc.  While you can use a FormLayout in\r
258             a standard panel, you will normally want to use a FormPanel directly in order to get form-specific functionality\r
259             like validation, submission, etc.  FormPanels use a FormLayout internally so the layout config is not needed\r
260             (and the layout may not render correctly if overridden).</p>\r
261             <p><b>Sample Config:</b></p>\r
262             <pre><code>\r
263 xtype: 'form', // FormPanel\r
264 labelWidth: 75,\r
265 width: 350,\r
266 defaultType: 'textfield',\r
267 items: [{\r
268         fieldLabel: 'First Name',\r
269         name: 'first',\r
270         allowBlank:false\r
271     },{\r
272         fieldLabel: 'Last Name',\r
273         name: 'last'\r
274     },{\r
275         fieldLabel: 'Company',\r
276         name: 'company'\r
277     },{\r
278         fieldLabel: 'Email',\r
279         name: 'email',\r
280         vtype:'email'\r
281     }\r
282 ],\r
283 buttons: [\r
284     {text: 'Save'},\r
285     {text: 'Cancel'}\r
286 ]\r
287             </code></pre>\r
288             <p><a href="http://extjs.com/deploy/dev/docs/?class=Ext.layout.FormLayout" target="_blank">API Reference</a></p>\r
289         </div>\r
290         <div id="table-details">\r
291             <h2>Ext.layout.TableLayout</h2>\r
292             <p>Outputs a standard HTML table as the layout container.  This is sometimes useful for complex layouts\r
293             where cell spanning is required, or when you want to allow the contents to flow naturally based on standard\r
294             browser table layout rules.</p>\r
295             <p><b>Sample Config:</b></p>\r
296             <pre><code>\r
297 layout:'table',\r
298 layoutConfig: {\r
299     columns: 3\r
300 },\r
301 items: [\r
302     {html:'1,1',rowspan:3},\r
303     {html:'1,2'},\r
304     {html:'1,3'},\r
305     {html:'2,2',colspan:2},\r
306     {html:'3,2'},\r
307     {html:'3,3'}\r
308 ]\r
309             </code></pre>\r
310             <p><a href="http://extjs.com/deploy/dev/docs/?class=Ext.layout.TableLayout" target="_blank">API Reference</a></p>\r
311         </div>\r
312 \r
313         <div id="vbox-details">\r
314             <h2>Ext.layout.VBoxLayout</h2>\r
315             <p>A layout that allows for the vertical and horizontal stretching of child items, much like the container\r
316             layout with size management.</p>\r
317             <p><b>Sample Config:</b></p>\r
318             <pre><code>\r
319 layout:'vbox',\r
320 layoutConfig: {\r
321     align : 'stretch',\r
322     pack  : 'start',\r
323 },\r
324 items: [\r
325     {html:'panel 1', flex:1},\r
326     {html:'panel 2', height:150},\r
327     {html:'panel 3', flex:2'}\r
328 ]\r
329             </code></pre>\r
330             <p><a href="http://extjs.com/deploy/dev/docs/?class=Ext.layout.VBoxLayout" target="_blank">API Reference</a></p>\r
331         </div>\r
332 \r
333         <div id="hbox-details">\r
334             <h2>Ext.layout.HBoxLayout</h2>\r
335             <p>A layout that allows for the vertical and horizontal stretching of child items, much like the column\r
336             layout but can stretch items vertically.</p>\r
337             <p><b>Sample Config:</b></p>\r
338             <pre><code>\r
339 layout:'hbox',\r
340 layoutConfig: {\r
341     align : 'stretch',\r
342     pack  : 'start',\r
343 },\r
344 items: [\r
345     {html:'panel 1', flex:1},\r
346     {html:'panel 2', width:150},\r
347     {html:'panel 3', flex:2'}\r
348 ]\r
349             </code></pre>\r
350             <p><a href="http://extjs.com/deploy/dev/docs/?class=Ext.layout.HBoxLayout" target="_blank">API Reference</a></p>\r
351         </div>\r
352 \r
353 \r
354         <!-- Custom layouts -->\r
355         <div id="row-details">\r
356             <h2>Ext.ux.layout.RowLayout</h2>\r
357             <p>This is a custom layout that is useful when you need a layout style with multiple rows of content.\r
358             Any fixed-height rows are calculated first, then any percentage-height rows specified using the\r
359             <tt>rowHeight</tt> config will be calculated based on remaining container height.  Percentages\r
360             should add up to 1 (100%) in order to fill the container. Standard panel widths (fixed or\r
361             percentage) are also supported.</p>\r
362             <p><b>Sample Config:</b></p>\r
363             <pre><code>\r
364 layout:'ux.row',\r
365 items: [{\r
366     title: 'Height = 25%',\r
367     rowHeight: .25,\r
368     width: '50%'\r
369 },{\r
370     title: 'Height = 100px',\r
371     height: 100,\r
372     width: 300\r
373 },{\r
374     title: 'Height = 75%',\r
375     rowHeight: .75\r
376 }]\r
377             </code></pre>\r
378         </div>\r
379         <div id="center-details">\r
380             <h2>Ext.ux.layout.CenterLayout</h2>\r
381             <p>This is a custom layout for centering contents within a container.  The only requirement is\r
382             that the container have a single child panel with a width specified (fixed or percentage).\r
383             The child panel can then contain  any content, including other components, that will display\r
384             centered within the main container. To make the centered panel non-visual, remove the title\r
385             and add <tt>border:false</tt> to the child config.</p>\r
386             <p><b>Sample Config:</b></p>\r
387             <pre><code>\r
388 layout:'ux.center',\r
389 items: {\r
390     title: 'Centered Panel',\r
391     width: '75%',\r
392     html: 'Some content'\r
393 }\r
394             </code></pre>\r
395         </div>\r
396 \r
397 \r
398         <!-- Combination layouts -->\r
399         <div id="tabs-nested-layouts-details">\r
400             <h2>Tabs With Nested Layouts</h2>\r
401             <p>There are multiple levels of layout nesting within three different TabPanels in this example.\r
402             Each tab in a TabPanel can have its own separate layout.  As we can see, some have plain content,\r
403             while others contain full BorderLayouts.  There is also a fully-loaded grid nested down inside\r
404             the inner-most tab, showing that there is no limit to how complex your layout can be.</p>\r
405             <p>One of the trickiest aspects of deeply nested layouts is dealing with borders on all the\r
406             different panels used in the layout.  In this example, body padding and region margins are used\r
407             extensively to provide space between components so that borders can be displayed naturally in\r
408             most cases. A different approach would be to minimize padding and use the config properties\r
409             related to borders to turn borders on and off selectively to achieve a slightly different look\r
410             and feel.</p>\r
411         </div>\r
412         <div id="complex-details">\r
413             <h2>Complex Layout</h2>\r
414             <p></p>\r
415         </div>\r
416 \r
417         <!-- Form layouts -->\r
418         <div id="abs-form-details">\r
419             <h2>Absolute Layout Form</h2>\r
420             <p>FormLayout supports absolute positioning in addition to standard anchoring for flexible control over\r
421             positioning of fields and labels in containers.  In this example, the top and left positions of the labels\r
422             and fields are positioned absolute, while the field widths are anchored to the right and/or bottom of the container.</p>\r
423         </div>\r
424     </div>\r
425 </body>\r
426 </html>\r