layout-browser.html 14 KB

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