3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js"><div id="cls-Ext.layout.ColumnLayout"></div>/**
\r
9 * @class Ext.layout.ColumnLayout
\r
10 * @extends Ext.layout.ContainerLayout
\r
11 * <p>This is the layout style of choice for creating structural layouts in a multi-column format where the width of
\r
12 * each column can be specified as a percentage or fixed width, but the height is allowed to vary based on the content.
\r
13 * This class is intended to be extended or created via the layout:'column' {@link Ext.Container#layout} config,
\r
14 * and should generally not need to be created directly via the new keyword.</p>
\r
15 * <p>ColumnLayout does not have any direct config options (other than inherited ones), but it does support a
\r
16 * specific config property of <b><tt>columnWidth</tt></b> that can be included in the config of any panel added to it. The
\r
17 * layout will use the columnWidth (if present) or width of each panel during layout to determine how to size each panel.
\r
18 * If width or columnWidth is not specified for a given panel, its width will default to the panel's width (or auto).</p>
\r
19 * <p>The width property is always evaluated as pixels, and must be a number greater than or equal to 1.
\r
20 * The columnWidth property is always evaluated as a percentage, and must be a decimal value greater than 0 and
\r
21 * less than 1 (e.g., .25).</p>
\r
22 * <p>The basic rules for specifying column widths are pretty simple. The logic makes two passes through the
\r
23 * set of contained panels. During the first layout pass, all panels that either have a fixed width or none
\r
24 * specified (auto) are skipped, but their widths are subtracted from the overall container width. During the second
\r
25 * pass, all panels with columnWidths are assigned pixel widths in proportion to their percentages based on
\r
26 * the total <b>remaining</b> container width. In other words, percentage width panels are designed to fill the space
\r
27 * left over by all the fixed-width and/or auto-width panels. Because of this, while you can specify any number of columns
\r
28 * with different percentages, the columnWidths must always add up to 1 (or 100%) when added together, otherwise your
\r
29 * layout may not render as expected. Example usage:</p>
\r
31 // All columns are percentages -- they must add up to 1
\r
32 var p = new Ext.Panel({
\r
33 title: 'Column Layout - Percentage Only',
\r
47 // Mix of width and columnWidth -- all columnWidth values must add up
\r
48 // to 1. The first column will take up exactly 120px, and the last two
\r
49 // columns will fill the remaining container width.
\r
50 var p = new Ext.Panel({
\r
51 title: 'Column Layout - Mixed',
\r
66 Ext.layout.ColumnLayout = Ext.extend(Ext.layout.ContainerLayout, {
\r
70 extraCls: 'x-column',
\r
75 isValidParent : function(c, target){
\r
76 return (c.getPositionEl ? c.getPositionEl() : c.getEl()).dom.parentNode == this.innerCt.dom;
\r
80 onLayout : function(ct, target){
\r
81 var cs = ct.items.items, len = cs.length, c, i;
\r
84 target.addClass('x-column-layout-ct');
\r
86 // the innerCt prevents wrapping and shuffling while
\r
87 // the container is resizing
\r
88 this.innerCt = target.createChild({cls:'x-column-inner'});
\r
89 this.innerCt.createChild({cls:'x-clear'});
\r
91 this.renderAll(ct, this.innerCt);
\r
93 var size = Ext.isIE && target.dom != Ext.getBody().dom ? target.getStyleSize() : target.getViewSize();
\r
95 if(size.width < 1 && size.height < 1){ // display none?
\r
99 var w = size.width - target.getPadding('lr') - this.scrollOffset,
\r
100 h = size.height - target.getPadding('tb'),
\r
103 this.innerCt.setWidth(w);
\r
105 // some columns can be percentages while others are fixed
\r
106 // so we need to make 2 passes
\r
108 for(i = 0; i < len; i++){
\r
110 if(!c.columnWidth){
\r
111 pw -= (c.getSize().width + c.getEl().getMargins('lr'));
\r
115 pw = pw < 0 ? 0 : pw;
\r
117 for(i = 0; i < len; i++){
\r
120 c.setSize(Math.floor(c.columnWidth*pw) - c.getEl().getMargins('lr'));
\r
125 <div id="prop-Ext.layout.ColumnLayout-activeItem"></div>/**
\r
126 * @property activeItem
\r
131 Ext.Container.LAYOUTS['column'] = Ext.layout.ColumnLayout;</pre>
\r