2 * @class Ext.grid.ColumnLayout
3 * @extends Ext.layout.container.HBox
6 * <p>This class is used only by the grid's HeaderContainer docked child.</p>
8 * <p>This class adds the ability to shrink the vertical size of the inner container element back if a grouped
9 * column header has all its child columns dragged out, and the whole HeaderContainer needs to shrink back down.</p>
11 * <p>It also enforces the grid's HeaderContainer's forceFit config by, after every calaculateChildBoxes call, converting
12 * all pixel widths into flex values, so that propertions are maintained upon width change of the grid.</p>
14 * <p>Also, after every layout, after all headers have attained their 'stretchmax' height, it goes through and calls
15 * <code>setPadding</code> on the columns so that they lay out correctly. TODO: implement a ColumnHeader component
16 * layout which takes responsibility for this, and will run upon resize.</p>
18 Ext.define('Ext.grid.ColumnLayout', {
19 extend: 'Ext.layout.container.HBox',
20 alias: 'layout.gridcolumn',
23 // Height-stretched innerCt must be able to revert back to unstretched height
24 clearInnerCtOnLayout: false,
26 constructor: function() {
28 me.callParent(arguments);
29 if (!Ext.isDefined(me.availableSpaceOffset)) {
30 me.availableSpaceOffset = (Ext.getScrollBarWidth() - 2);
34 beforeLayout: function() {
37 items = me.getLayoutItems(),
41 returnValue = me.callParent(arguments);
43 // Size to a sane minimum height before possibly being stretched to accommodate grouped headers
44 me.innerCt.setHeight(23);
46 // Unstretch child items before the layout which stretches them.
47 if (me.align == 'stretchmax') {
48 for (; i < len; i++) {
53 item.titleContainer.setStyle({
57 if (item.componentLayout && item.componentLayout.lastComponentSize) {
58 item.componentLayout.lastComponentSize.height = item.el.dom.offsetHeight;
65 // Override to enforce the forceFit config.
66 calculateChildBoxes: function(visibleItems, targetSize) {
68 calculations = me.callParent(arguments),
69 boxes = calculations.boxes,
70 metaData = calculations.meta,
71 len = boxes.length, i = 0, box, item;
73 if (targetSize.width && !me.isColumn) {
74 // If configured forceFit then all columns will be flexed
75 if (me.owner.forceFit) {
77 for (; i < len; i++) {
81 // Set a sane minWidth for the Box layout to be able to squeeze flexed Headers down to.
82 item.minWidth = Ext.grid.plugin.HeaderResizer.prototype.minColWidth;
84 // For forceFit, just use allocated width as the flex value, and the proportions
85 // will end up the same whatever HeaderContainer width they are being forced into.
86 item.flex = box.width;
89 // Recalculate based upon all columns now being flexed instead of sized.
90 calculations = me.callParent(arguments);
92 else if (metaData.tooNarrow) {
93 targetSize.width = metaData.desiredSize;
100 afterLayout: function() {
103 items = me.getLayoutItems(),
106 me.callParent(arguments);
108 // Set up padding in items
109 if (me.align == 'stretchmax') {
110 for (; i < len; i++) {
111 items[i].setPadding();
116 // FIX: when flexing we actually don't have enough space as we would
117 // typically because of the scrollOffset on the GridView, must reserve this
118 updateInnerCtSize: function(tSize, calcs) {
122 // Columns must not account for scroll offset
123 if (!me.isColumn && calcs.meta.tooNarrow) {
127 (Ext.isIEQuirks && (Ext.isIE6 || Ext.isIE7 || Ext.isIE8))
131 } else if (Ext.isIE6 || Ext.isIE7 || Ext.isIE8) {
135 // this is the 1px accounted for in the Scroller when subtracting 1px.
137 tSize.width = calcs.meta.desiredSize + (me.reserveOffset ? me.availableSpaceOffset : 0) + extra;
139 return me.callParent(arguments);
142 doOwnerCtLayouts: function() {
143 var ownerCt = this.owner.ownerCt;
144 if (!ownerCt.componentLayout.layoutBusy) {
145 ownerCt.doComponentLayout();