dmallory
29 Apr 2009, 8:31 AM
My team has encountered the following issue in 2.0-M1, including a build from svn as of last weekend.
On various combinations of layouts, seemingly when a CardLayout is involved, percentage height/width values are converted to raw pixels in the final HTML. For example, 100% becomes 100px, 95% becomes 95px, etc. This causes significant problems for applications with heavy height/width 100% usage. Workarounds require deriving height/weight more explicitly from parents or reworking the component hierarchy to sidestep the problematic combinations.
For example, the following code:
ContentPanel searchContentPanel= new ContentPanel();
searchContentPanel.setId("broken-width-example-contentpanel-id");
searchContentPanel.setLayout(new RowLayout(Orientation.VERTICAL));
searchContentPanel.setWidth("100%");
searchContentPanel.setHeight("100%");
searchContentPanel.setHeaderVisible(true);
searchContentPanel.setHeading("Search");
searchContentPanel.setBorders(false);
searchContentPanel.setBodyBorder(false);
searchContentPanel.setFrame(true);
searchContentPanel.add(new LabelField("Search Goes Here"));
LayoutContainer layoutContainer = new LayoutContainer();
layoutContainer.setId("broken-width-example-layout-id");
layoutContainer.setWidth("100%");
layoutContainer.setHeight("100%");
layoutContainer.setLayout(cardLayout);
layoutContainer.add(searchContentPanel);
produces the following HTML:
<div id="broken-width-example-layout-id" style="width: 100%; height: 100%;">
<div id="broken-width-example-contentpanel-id" class="x-panel-noborder x-panel" style="border-width: 0px; width: 100px;">
<div class="x-panel-tl">
<div class="x-panel-tr">
<div class="x-panel-tc">
<div id="x-auto-222" class="x-small-editor x-panel-header x-unselectable" unselectable="on">
<div id="x-auto-220" class="x-icon-btn x-nodrag x-panel-inline-icon x-hide-display" style="cursor: default; float: left;"/>
<div id="x-auto-221" class="x-panel-toolbar" style="overflow: visible;">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr/>
</tbody>
</table>
</div>
<span id="x-auto-222-label" class="x-panel-header-text">Search</span>
</div>
</div>
</div>
</div>
<div class="x-panel-bwrap">
<div class="x-panel-ml">
<div class="x-panel-mr">
<div class="x-panel-mc">
<div class="x-panel-body x-panel-body-noborder" style="overflow: hidden; width: 88px; height: 65px;">
<div id="x-auto-223" class="x-form-label">Search Goes Here</div>
</div>
</div>
</div>
</div>
<div class="x-panel-bl x-panel-nofooter">
<div class="x-panel-br">
<div class="x-panel-bc">
<div class="x-panel-footer"/>
</div>
</div>
</div>
</div>
</div>
</div>
Note that the width is 100px rather than 100% in the second div. We encountered this on upgrade on a project that had otherwise rendered correctly using GXT 1.2.3.
On various combinations of layouts, seemingly when a CardLayout is involved, percentage height/width values are converted to raw pixels in the final HTML. For example, 100% becomes 100px, 95% becomes 95px, etc. This causes significant problems for applications with heavy height/width 100% usage. Workarounds require deriving height/weight more explicitly from parents or reworking the component hierarchy to sidestep the problematic combinations.
For example, the following code:
ContentPanel searchContentPanel= new ContentPanel();
searchContentPanel.setId("broken-width-example-contentpanel-id");
searchContentPanel.setLayout(new RowLayout(Orientation.VERTICAL));
searchContentPanel.setWidth("100%");
searchContentPanel.setHeight("100%");
searchContentPanel.setHeaderVisible(true);
searchContentPanel.setHeading("Search");
searchContentPanel.setBorders(false);
searchContentPanel.setBodyBorder(false);
searchContentPanel.setFrame(true);
searchContentPanel.add(new LabelField("Search Goes Here"));
LayoutContainer layoutContainer = new LayoutContainer();
layoutContainer.setId("broken-width-example-layout-id");
layoutContainer.setWidth("100%");
layoutContainer.setHeight("100%");
layoutContainer.setLayout(cardLayout);
layoutContainer.add(searchContentPanel);
produces the following HTML:
<div id="broken-width-example-layout-id" style="width: 100%; height: 100%;">
<div id="broken-width-example-contentpanel-id" class="x-panel-noborder x-panel" style="border-width: 0px; width: 100px;">
<div class="x-panel-tl">
<div class="x-panel-tr">
<div class="x-panel-tc">
<div id="x-auto-222" class="x-small-editor x-panel-header x-unselectable" unselectable="on">
<div id="x-auto-220" class="x-icon-btn x-nodrag x-panel-inline-icon x-hide-display" style="cursor: default; float: left;"/>
<div id="x-auto-221" class="x-panel-toolbar" style="overflow: visible;">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr/>
</tbody>
</table>
</div>
<span id="x-auto-222-label" class="x-panel-header-text">Search</span>
</div>
</div>
</div>
</div>
<div class="x-panel-bwrap">
<div class="x-panel-ml">
<div class="x-panel-mr">
<div class="x-panel-mc">
<div class="x-panel-body x-panel-body-noborder" style="overflow: hidden; width: 88px; height: 65px;">
<div id="x-auto-223" class="x-form-label">Search Goes Here</div>
</div>
</div>
</div>
</div>
<div class="x-panel-bl x-panel-nofooter">
<div class="x-panel-br">
<div class="x-panel-bc">
<div class="x-panel-footer"/>
</div>
</div>
</div>
</div>
</div>
</div>
Note that the width is 100px rather than 100% in the second div. We encountered this on upgrade on a project that had otherwise rendered correctly using GXT 1.2.3.