jay@moduscreate.com
6 Jan 2009, 1:39 PM
http://tdg-i.com/img/screencasts/2009-01-06_1641.png
Ext.override(Ext.layout.ColumnLayout, {
onLayout : function(ct, target){
var cs = ct.items.items, len = cs.length, c, i;
if(!this.innerCt){
target.addClass('x-column-layout-ct');
// the innerCt prevents wrapping and shuffling while
// the container is resizing
this.innerCt = target.createChild({cls:'x-column-inner'});
this.innerCt.createChild({cls:'x-clear'});
}
this.renderAll(ct, this.innerCt);
var size = Ext.isIE && target.dom != Ext.getBody().dom ? target.getStyleSize() : target.getViewSize();
if(size.width < 1 && size.height < 1){ // display none?
return;
}
var w = size.width - target.getPadding('lr') - this.scrollOffset,
h = size.height - target.getPadding('tb'),
pw = w;
this.innerCt.setWidth(w);
// some columns can be percentages while others are fixed
// so we need to make 2 passes
for(i = 0; i < len; i++){
c = cs[i];
if(!c.columnWidth){
pw -= (c.getSize().width + c.getEl().getMargins('lr'));
}
}
pw = pw < 0 ? 0 : pw;
for(i = 0; i < len; i++){
c = cs[i];
if(c.columnWidth){
c.setSize(Math.floor(c.columnWidth*pw) - c.getEl().getMargins('lr'));
}
if (c.columnHeight) {//New code here
c.setHeight(size.height * c.columnHeight);
}
}
}
});
test usage:
new Ext.Window({
height : 200,
width : 400,
border : false,
autoScroll : true,
id : 'myWin',
title : 'A Window with a Card layout',
layout : 'column',
defaults : {
frame : true
},
items : [
{
title : 'Col 1',
id : 'col1',
columnWidth : .3,
columnHeight : 1,
layout : 'fit',
items : {
xtype : 'panel',
title : 'blah',
html : 'blah',
frame : true
}
},
{
title : 'Col 2',
html : "20% relative width",
columnWidth : .2
},
{
title : 'Col 3',
html : "100px fixed width",
width : 100,
columnHeight : 1
},
{
title : 'Col 4',
frame : true,
html : "50% relative width",
columnWidth : .5,
columnHeight : 1
}
]
});
untested with anything but fx3 on the mac
Ext.override(Ext.layout.ColumnLayout, {
onLayout : function(ct, target){
var cs = ct.items.items, len = cs.length, c, i;
if(!this.innerCt){
target.addClass('x-column-layout-ct');
// the innerCt prevents wrapping and shuffling while
// the container is resizing
this.innerCt = target.createChild({cls:'x-column-inner'});
this.innerCt.createChild({cls:'x-clear'});
}
this.renderAll(ct, this.innerCt);
var size = Ext.isIE && target.dom != Ext.getBody().dom ? target.getStyleSize() : target.getViewSize();
if(size.width < 1 && size.height < 1){ // display none?
return;
}
var w = size.width - target.getPadding('lr') - this.scrollOffset,
h = size.height - target.getPadding('tb'),
pw = w;
this.innerCt.setWidth(w);
// some columns can be percentages while others are fixed
// so we need to make 2 passes
for(i = 0; i < len; i++){
c = cs[i];
if(!c.columnWidth){
pw -= (c.getSize().width + c.getEl().getMargins('lr'));
}
}
pw = pw < 0 ? 0 : pw;
for(i = 0; i < len; i++){
c = cs[i];
if(c.columnWidth){
c.setSize(Math.floor(c.columnWidth*pw) - c.getEl().getMargins('lr'));
}
if (c.columnHeight) {//New code here
c.setHeight(size.height * c.columnHeight);
}
}
}
});
test usage:
new Ext.Window({
height : 200,
width : 400,
border : false,
autoScroll : true,
id : 'myWin',
title : 'A Window with a Card layout',
layout : 'column',
defaults : {
frame : true
},
items : [
{
title : 'Col 1',
id : 'col1',
columnWidth : .3,
columnHeight : 1,
layout : 'fit',
items : {
xtype : 'panel',
title : 'blah',
html : 'blah',
frame : true
}
},
{
title : 'Col 2',
html : "20% relative width",
columnWidth : .2
},
{
title : 'Col 3',
html : "100px fixed width",
width : 100,
columnHeight : 1
},
{
title : 'Col 4',
frame : true,
html : "50% relative width",
columnWidth : .5,
columnHeight : 1
}
]
});
untested with anything but fx3 on the mac