PDA

View Full Version : [CLOSED] Table in BorderLayout Problem.



Canto
28 Apr 2008, 10:52 PM
Hello. Sorry for not posting problem in one class but it would be just too much code and confusion.
The problem is in table I've created. It's dissapearing when i minimize <-> maximize my window. Reproducable in gwt hosted mode browser and in firefox3 (dunno about other browser, i didn't tested. I hope You could manage to include this patch in beta2!

Poczekalnia.java


import com.extjs.gxt.ui.client.Style.SelectionMode;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Viewport;
import com.extjs.gxt.ui.client.widget.layout.FillLayout;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
import com.extjs.gxt.ui.client.widget.table.NumberCellRenderer;
import com.extjs.gxt.ui.client.widget.table.Table;
import com.extjs.gxt.ui.client.widget.table.TableColumn;
import com.extjs.gxt.ui.client.widget.table.TableColumnModel;
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.TextToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.i18n.client.NumberFormat;

public class Poczekalnia extends Viewport {

public Poczekalnia() {
this.setLayout(new FillLayout(8));
this.create();
this.layout();
}

public void create() {
FlowLayout layout = new FlowLayout();
layout.margin = 10;
setLayout(layout);

List<TableColumn> columns = new ArrayList<TableColumn>();
TableColumn nazwa = new TableColumn("Podmiot", 200);
nazwa.setMaxWidth(300);
TableColumn kwota = new TableColumn("Kwota", 50);
kwota.setMaxWidth(100);
kwota.setRenderer(new NumberCellRenderer(NumberFormat
.getCurrencyFormat()));
TableColumn status = new TableColumn("Status", 50);
status.setMaxWidth(50);

columns.add(nazwa);
columns.add(kwota);
columns.add(status);

TableColumnModel<TableColumn> cm = new TableColumnModel<TableColumn>(columns);
Table tbl = new Table(cm);

tbl.selectionMode = SelectionMode.MULTI;
tbl.horizontalScroll = true;

ContentPanel cp = new ContentPanel();
cp.collapsible = true;
cp.setHeading("Poczekalnia");
cp.frame = true;
cp.setLayout(new FitLayout());
cp.add(tbl);
cp.setWidth("100%");
cp.setHeight(400);

ToolBar tb = new ToolBar();
tb.add(new TextToolItem("Dodaj", "icon-add"));
tb.add(new SeparatorToolItem());
tb.add(new TextToolItem("Usuń", "icon-delete"));
tb.add(new SeparatorToolItem());
tb.add(new TextToolItem("Przenies", "icon-plugin"));
cp.setTopComponent(tb);

add(cp);
}
}
Platnosci.java


import Poczekalnia;

import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.Container;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Viewport;
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;

public class Platnosci extends Container implements EntryPoint {

RootPanel rootPanel = RootPanel.get();

public void onModuleLoad() {

Viewport v = new Viewport();

v.setLayout(new BorderLayout());

ContentPanel north = new ContentPanel();
ContentPanel west = new ContentPanel();
ContentPanel center = new ContentPanel();
ContentPanel east = new ContentPanel();
ContentPanel south = new ContentPanel();

north.setSize("200px", "200px");

BorderLayoutData northData = new BorderLayoutData(LayoutRegion.NORTH, 200);
northData.split = true;
northData.margins = new Margins(5, 5, 0, 5);

BorderLayoutData westData = new BorderLayoutData(LayoutRegion.WEST);
westData.split = true;
westData.collapsible = true;
westData.margins = new Margins(5, 5, 5, 5);

BorderLayoutData centerData = new BorderLayoutData(LayoutRegion.CENTER);
centerData.margins = new Margins(5, 0, 5, 0);

BorderLayoutData eastData = new BorderLayoutData(LayoutRegion.EAST);
eastData.split = true;
eastData.collapsible = true;
eastData.margins = new Margins(5, 5, 5, 5);

east.add(new Poczekalnia());

BorderLayoutData southData = new BorderLayoutData(LayoutRegion.SOUTH, 100);
southData.split = true;
southData.collapsible = true;
southData.margins = new Margins(0, 5, 5, 5);

v.add(north, northData);
v.add(west, westData);
v.add(center, centerData);
v.add(east, eastData);
v.add(south, southData);

v.layout(true);

rootPanel.add(v);
}
}

darrellmeyer
29 Apr 2008, 8:18 PM
You are not using containers and layouts properly.

In your code you give the viewport 3 different layouts (FillLayout, FlowLayout, and BorderLayout).

When using a BorderLayout you should not size the child components. That is the job of the layout.

You should also avoid percentage based sizes in most cases. You are setting a width to 100%.

Try taking a look at the explorer demo code so sample usage. Also, you can use Firebug with Firefox to inspect the DOM to see what is happening in you page.