JamesC
28 Nov 2007, 3:37 AM
Hi,
Thought i'd share my experiences on how I managed to get my column tree to automatically reisize when you resize its container.
// Assuming column tree already setup with 4 columns
// widths array controls the percentages to resize the columns to
var tree = *YourTreeComponent*
var treecontainer = *YourTreesContainer*
treecontainer.on("resize", function() {
var treeWidth = treecontainer.getSize().width;
var bw = Ext.isBorderBox ? 0 : 2;
var widths = [(treeWidth*0.64), (treeWidth*0.12), (treeWidth*0.12), (treeWidth*0.12)];
var totalWidth = 0;
for (var i = 0; i < widths.length; i++) {
totalWidth += widths[i];
Ext.select("div.x-tree-hd:nth-child(" + (i+1) + ")", false, "*TreeID*").setWidth(widths[i] - bw);
Ext.select("div.x-tree-col:nth-child(" + (i+1) + ")", false, "*TreeID*").setWidth(widths[i] - bw);
tree.columns[i].width = widths[i];
}
tree.headers.setWidth(totalWidth);
tree.innerCt.setWidth(totalWidth);
});
Hope this is useful, or if theres a better way please let me know!
Cheers!
James
Thought i'd share my experiences on how I managed to get my column tree to automatically reisize when you resize its container.
// Assuming column tree already setup with 4 columns
// widths array controls the percentages to resize the columns to
var tree = *YourTreeComponent*
var treecontainer = *YourTreesContainer*
treecontainer.on("resize", function() {
var treeWidth = treecontainer.getSize().width;
var bw = Ext.isBorderBox ? 0 : 2;
var widths = [(treeWidth*0.64), (treeWidth*0.12), (treeWidth*0.12), (treeWidth*0.12)];
var totalWidth = 0;
for (var i = 0; i < widths.length; i++) {
totalWidth += widths[i];
Ext.select("div.x-tree-hd:nth-child(" + (i+1) + ")", false, "*TreeID*").setWidth(widths[i] - bw);
Ext.select("div.x-tree-col:nth-child(" + (i+1) + ")", false, "*TreeID*").setWidth(widths[i] - bw);
tree.columns[i].width = widths[i];
}
tree.headers.setWidth(totalWidth);
tree.innerCt.setWidth(totalWidth);
});
Hope this is useful, or if theres a better way please let me know!
Cheers!
James