|
|||||||
![]() |
|
|
Thread Tools |
|
#1
|
|||
|
|||
|
Hi
I have a ‘Ext.ux.tree.ColumnTree’ with a declared width = ‘100%’. Inside, I define 3 columns and I would like to declare width for this columns in ‘%’( something like ‘30%’,’30%’ and ‘40%’). If I use ‘%’ in width declaration, it won’t work (both IE and FF) and I am forced to declare width in px. Do you have any idée for my problem? Thanks |
|
#2
|
|||
|
|||
|
Hiya,
I now have the same requirement (column widths as percentages), so I am going to have a look at the code for grids and see how they do it. If I come up with a good solution I will post it back. Let me know if you have already done this though ![]() Em |
|
#3
|
|||
|
|||
|
Hello friends,
Did you find some solution??? Bets regards, Silver |
|
#4
|
|||
|
|||
|
Kinda, but it isn't very nice. I have done it so that the ColumnTree can be set to fill its container. I set it up so that you have to put an 'autoExpand' config attribute in, then it takes whatever dimensions you have given your columns and keeps their ratio. This means you can give them in %, but you can also use px and not have it expand.
Basically getting the header to resize was ok, but for the tree nodes, I had to edit renderElements in ColumnNodeUI to give them another class 'depth-' + i where i is the column id, then go through and resize the element widths. This is my resize callback: 'resize': {
fn: function(ob, adjWidth, adjHeight, rawWidth, rawHeight) {
if (adjWidth && adjHeight) {
if (this.autoExpand) {
this.setSize(ob.getInnerWidth());
this.headers.setWidth(ob.getInnerWidth());
this.innerCt.setWidth(ob.getInnerWidth() - 19);
var totalWidth = 0;
for (var i = 0; i < this.columns.length; i++) {
totalWidth += this.columns[i].width;
}
var availWidth = adjWidth;
var multiplier = (availWidth - 19) / totalWidth;
for (var i = 0; i < this.columns.length; i++) {
this.columns[i].width = this.columns[i].width * multiplier;
}
var headerCols = this.headers.dom.children;
for (var i =0; i < headerCols.length; i++) {
if (i < this.columns.length) {
if (i == 0) {
headerCols[i].style.width = (this.columns[i].width - 2 * this.borderWidth) + 'px';
} else {
headerCols[i].style.width = (this.columns[i].width - this.borderWidth) + 'px';
}
}
}
if (this.root.childNodes.length > 0) {
var cols = Ext.select('div.x-tree-col').elements;
var depth_re = /depth-(\d+)/;
for (var data_i = 0; data_i < cols.length; data_i++) {
if (cols[data_i].className) {
match = depth_re.exec(cols[data_i].className)
if (!!match) {
var i = match[1];
if (i == '0') {
cols[data_i].style.width = this.columns[i].width - 2 * this.borderWidth + 'px';
} else {
cols[data_i].style.width = this.columns[i].width - this.borderWidth + 'px';
}
}
}
}
}
}
}
}
}
What I think ought to happen is that you create CSS classes ('depth-' +coulmn_index) when you are creating the elements, then change the width attribute in those css classes. I don't think I know how to do this (although I haven't really researched it). Anyone got any better ideas? |
|
#5
|
||||
|
||||
|
i haven't worked it out myself
but it should be easy enough by using anchorlayout var viewport = new Ext.Viewport({
layout:'anchor',
anchorSize: {width:800, height:600},
items:[{
title:'Item 1',
html:'Content 1',
width:800,
anchor:'right 20%'
},{
title:'Item 2',
html:'Content 2',
width:300,
anchor:'50% 30%'
},{
title:'Item 3',
html:'Content 3',
width:600,
anchor:'-100 50%'
}]
});
|
|
#6
|
|||
|
|||
|
Quote:
|
|
#7
|
||||
|
||||
|
it should work fine when you give your columntree the layout anchor
and then define for eacht column the anchor like below anchor : String This configuation option is to be applied to child items of a container managed by this layout (ie. configured with layout:'anchor'). This value is what tells the layout how an item should be anchored to the container. items added to an AnchorLayout accept an anchoring-specific config property of anchor which is a string containing two values: the horizontal anchor value and the vertical anchor value (for example, '100% 50%'). The following types of anchor values are supported:
|
|
#8
|
|||
|
|||
|
Quote:
|
|
#9
|
||||
|
||||
|
it will work fine because anchor can be applied to every item as long as the component where this item is on has been extended by container,
just give the container layout :'anchor' |
|
#10
|
|||
|
|||
|
Quote:
Do you want to give us some example code? |
![]() |
| Thread Tools | |
|
|