PDA

View Full Version : Annoying mind-bending hidden content problem



MikeV
21 Jul 2007, 2:03 AM
Hi,

I've been trying to figure this out for a while, but without any luck!

I've been working on something: http://mikev.ath.cx/mike/site/uitest.html
It has two tabs, each tab has a similar layout (treeview on the left, grid on the right).

The thing is, whichever tab is out of focus during load time is the tab that has a messed up layout. If you click on "Manage Mixes", you will notice that the "center" (right) content does not appear - but it will appear if you play with the splitter. This is because the div of the center content (and all its children) have a width of 0px for some reason.

If I make the "Manage Mixes" tab active on load (tabs.activate('tabmixes');) then the Manage Files tab gets the screwy layout.


Is this a problem with my code or is it a possible bug in ExtJS 1.1RC1 ?

Thanks!

MikeV
23 Jul 2007, 7:04 AM
Ok, I've created a stripped down version of the test: http://mikev.ath.cx/mike/site/test.html

test.html is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>UI Test</title>

<script type="text/javascript" src="templates/include/ext/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="templates/include/ext/ext-all.js"></script>
<script type="text/javascript" src="templates/include/test.js"></script>

<!-- Include Ext stylesheets here: -->
<link rel="stylesheet" type="text/css" href="templates/include/ext/resources/css/ext-all.css">
<link rel="stylesheet" type="text/css" href="templates/include/ext/resources/css/xtheme-aero.css">
</head>
<body>

<!-- The tabs -->
<div id="tabs">
<div id="tabfiles" class="tab-content">
<div id="file-ct" style="width:auto;height:800px;"></div>
</div>

<div id="tabmixes" class="tab-content">
<div id="mix-ct" style="width:auto;height:800px;"></div>
</div>

</body>
</html>

test.js is:

var ManageMixes = {
init : function(){
// File view
var cview = Ext.DomHelper.append('mix-ct',
{cn:[{id:'main-tb2'},{id:'cbody2'}]}
);

// Category view
var cnav = Ext.DomHelper.append('mix-ct',
{cn:[{id:'nav-tb2'},{id:'cnavtree2'}]}
);

// create our layout
var layout = new Ext.BorderLayout('mix-ct', {
west: {
split:true,
initialSize: 230,
minSize: 175,
maxSize: 400,
titlebar: true,
margins:{left:5,right:0,bottom:5,top:5}
},
center: {
title: 'Files',
margins:{left:0,right:5,bottom:5,top:5}
}
}, 'mix-ct');


var cm = new Ext.grid.ColumnModel([{
header: "test",
width: 100
},{
header: "test",
width: 100
}
]);
var ds = new Ext.data.Store({});

// create the editor grid
var grid = new Ext.grid.EditorGrid('cbody2', {
ds: ds,
cm: cm,
selModel: new Ext.grid.RowSelectionModel({singleSelect:false}),
enableColLock:false
});

// render it
grid.render();

layout.beginUpdate();
layout.add("west", new Ext.ContentPanel(cnav, {
autoCreate:true,
title:'Categories',
autoScroll:true,
fitToFrame:true
}));
layout.add("center", new Ext.GridPanel(grid, {
autoScroll:true,
initialSize: 100,
minSize: 100,
fitToFrame:true,
resizeEl:'cbody2'
}));
layout.endUpdate();
}
};


/******************************************************************************************************************************************************/

var ManageFiles = {
init : function(){

// File view
var cview = Ext.DomHelper.append('file-ct',
{cn:[{id:'main-tb'},{id:'cbody'}]}
);

// Category view
var cnav = Ext.DomHelper.append('file-ct',
{cn:[{id:'nav-tb'},{id:'cnavtree'}]}
);

// create our layout
var layout = new Ext.BorderLayout('file-ct', {
west: {
split:true,
initialSize: 230,
minSize: 175,
maxSize: 400,
titlebar: true,
margins:{left:5,right:0,bottom:5,top:5}
},
center: {
title: 'Files',
margins:{left:0,right:5,bottom:5,top:5}
}
}, 'file-ct');


var cm = new Ext.grid.ColumnModel([{
header: "test",
width: 100
},{
header: "test",
width: 100
}
]);
var ds = new Ext.data.Store({});

// create the editor grid
var grid = new Ext.grid.EditorGrid('cbody', {
ds: ds,
cm: cm,
selModel: new Ext.grid.RowSelectionModel({singleSelect:false}),
enableColLock:false
});

// render it
grid.render();

layout.beginUpdate();
layout.add("west", new Ext.ContentPanel(cnav, {
autoCreate:true,
title:'Categories',
autoScroll:true,
fitToFrame:true
}));
layout.add("center", new Ext.GridPanel(grid, {
autoScroll:true,
initialSize: 100,
minSize: 100,
fitToFrame:true,
resizeEl:'cbody'
}));
layout.endUpdate();
}
}


var TabBar = {
init : function(){
var tabs = new Ext.TabPanel('tabs');
tabs.addTab('tabfiles', "Manage Files");
tabs.addTab('tabmixes', "Manage Mixes");
tabs.activate('tabfiles');

}
}

Ext.onReady(function(){
TabBar.init();
ManageFiles.init();
ManageMixes.init();
});

jay@moduscreate.com
23 Jul 2007, 9:50 AM
sounds like a dj site content manager ;)

MikeV
23 Jul 2007, 6:34 PM
It's actually a pretty simple project. You create categories, put mp3s in them and it generates dynamic forms that lets people to pick which mp3 of which category to use and it mixes them together.

But that's not the point ;-)

The point is that for some reason the layout is hidden and I can't really figure it out, so I'm at the mercy of experts who can!

I'd be very grateful if anyone could help me fix this!

PFM
23 Jul 2007, 7:21 PM
Just kinda guessing here... try setting a height and width on the div's for the tabs

<div id="tabmixes" class="tab-content" style="width:600px;height:800px;">

See http://extjs.com/learn/Tutorial:Using_Layouts_with_Ext_-_Part_1


An important note for Internet Explorer: The element that will contain your BorderLayout must have size in order for it to render properly. This typically isn't a problem if you're writing an application that uses the document.body since document.body always has size (well mostly anyway - if it didn't we wouldn't see anything in the browser.) But if you're using layout management within containers on an existing web page (perhaps in a DIV) you'll need to give that DIV size in order for the layout to render. Something like this works fine:

<div style="height:400px;"></div>

MikeV
23 Jul 2007, 11:10 PM
Just kinda guessing here... try setting a height and width on the div's for the tabs

<div id="tabmixes" class="tab-content" style="width:600px;height:800px;">

See http://extjs.com/learn/Tutorial:Using_Layouts_with_Ext_-_Part_1

PFM, that has actually worked!

By the way, is there a way to make it use width:100% ? Because when i set it to 100% the same problem creeps up. It only seems to work with absolute lengths.

MikeV
23 Jul 2007, 11:22 PM
Oh MY God! :)

I've fixed it... I was setting the style on the wrong div, I was setting it on the tab content instead of the tab itself!

Thanks alot guys, I really appreciate it!

jjohnson
24 Jul 2007, 8:48 AM
I am having the same issue what did you do to fix it?