4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-grid-ColumnLayout'>/**
19 </span> * @class Ext.grid.ColumnLayout
20 * @extends Ext.layout.container.HBox
23 * <p>This class is used only by the grid's HeaderContainer docked child.</p>
25 * <p>This class adds the ability to shrink the vertical size of the inner container element back if a grouped
26 * column header has all its child columns dragged out, and the whole HeaderContainer needs to shrink back down.</p>
28 * <p>It also enforces the grid's HeaderContainer's forceFit config by, after every calaculateChildBoxes call, converting
29 * all pixel widths into flex values, so that propertions are maintained upon width change of the grid.</p>
31 * <p>Also, after every layout, after all headers have attained their 'stretchmax' height, it goes through and calls
32 * <code>setPadding</code> on the columns so that they lay out correctly. TODO: implement a ColumnHeader component
33 * layout which takes responsibility for this, and will run upon resize.</p>
35 Ext.define('Ext.grid.ColumnLayout', {
36 extend: 'Ext.layout.container.HBox',
37 alias: 'layout.gridcolumn',
40 // Height-stretched innerCt must be able to revert back to unstretched height
41 clearInnerCtOnLayout: false,
43 constructor: function() {
45 me.callParent(arguments);
46 if (!Ext.isDefined(me.availableSpaceOffset)) {
47 me.availableSpaceOffset = (Ext.getScrollBarWidth() - 2);
51 beforeLayout: function() {
54 items = me.getLayoutItems(),
58 returnValue = me.callParent(arguments);
60 // Size to a sane minimum height before possibly being stretched to accommodate grouped headers
61 me.innerCt.setHeight(23);
63 // Unstretch child items before the layout which stretches them.
64 if (me.align == 'stretchmax') {
65 for (; i < len; i++) {
70 item.titleContainer.setStyle({
74 if (item.componentLayout && item.componentLayout.lastComponentSize) {
75 item.componentLayout.lastComponentSize.height = item.el.dom.offsetHeight;
82 // Override to enforce the forceFit config.
83 calculateChildBoxes: function(visibleItems, targetSize) {
85 calculations = me.callParent(arguments),
86 boxes = calculations.boxes,
87 metaData = calculations.meta,
88 len = boxes.length, i = 0, box, item;
90 if (targetSize.width && !me.isColumn) {
91 // If configured forceFit then all columns will be flexed
92 if (me.owner.forceFit) {
94 for (; i < len; i++) {
98 // Set a sane minWidth for the Box layout to be able to squeeze flexed Headers down to.
99 item.minWidth = Ext.grid.plugin.HeaderResizer.prototype.minColWidth;
101 // For forceFit, just use allocated width as the flex value, and the proportions
102 // will end up the same whatever HeaderContainer width they are being forced into.
103 item.flex = box.width;
106 // Recalculate based upon all columns now being flexed instead of sized.
107 calculations = me.callParent(arguments);
109 else if (metaData.tooNarrow) {
110 targetSize.width = metaData.desiredSize;
117 afterLayout: function() {
120 items = me.getLayoutItems(),
123 me.callParent(arguments);
125 // Set up padding in items
126 if (me.align == 'stretchmax') {
127 for (; i < len; i++) {
128 items[i].setPadding();
133 // FIX: when flexing we actually don't have enough space as we would
134 // typically because of the scrollOffset on the GridView, must reserve this
135 updateInnerCtSize: function(tSize, calcs) {
139 // Columns must not account for scroll offset
140 if (!me.isColumn && calcs.meta.tooNarrow) {
144 (Ext.isIEQuirks && (Ext.isIE6 || Ext.isIE7 || Ext.isIE8))
148 } else if (Ext.isIE6 || Ext.isIE7 || Ext.isIE8) {
152 // this is the 1px accounted for in the Scroller when subtracting 1px.
154 tSize.width = calcs.meta.desiredSize + (me.reserveOffset ? me.availableSpaceOffset : 0) + extra;
156 return me.callParent(arguments);
159 doOwnerCtLayouts: function() {
160 var ownerCt = this.owner.ownerCt;
161 if (!ownerCt.componentLayout.layoutBusy) {
162 ownerCt.doComponentLayout();