PDA

View Full Version : How to make XmlTablePage fit in full size of table panel



budhimind
8 Jun 2008, 9:02 AM
Hi,
In Explorer demo,
I would like XmlTablePage displayed to fit in table panel in stead of set to fixed size.
Any one nows?
Thanks

darrellmeyer
8 Jun 2008, 8:30 PM
Place the table in a LayoutContainer with a FitLayout. The table will then be sized to fit the parent container.

budhimind
9 Jun 2008, 3:43 AM
Thanks for the reply!

Following you suggestion, I just take out Panel container and add table direct into XmlTablePage's container. The horizontal size is fit to it's parent but not vertical.
It has the same result if I take panel.setSize(575, 350) out from the code.


public class XmlTablePage extends LayoutContainer implements EntryPoint {
...
@Override
protected void onRender(Element parent, int pos) {
super.onRender(parent, pos);

setLayout(new FlowLayout(10));
//setLayout(new FitLayout());
...
...
...
XmlReader reader = new XmlReader(type);

final BaseListLoader loader = new BaseListLoader(proxy, reader);

new TableBinder(table, new ListStore(loader));

ContentPanel panel = new ContentPanel();
panel.setFrame(true);
panel.setCollapsible(true);
panel.setAnimCollapse(false);
panel.setButtonAlign(HorizontalAlignment.CENTER);
panel.setIconStyle("icon-table");
panel.setHeading("XML Table Demo");
panel.setLayout(new FitLayout());
panel.add(table);
//panel.setSize(575, 350);

// add buttons
Button load = new Button("Load XML");
load.addSelectionListener(new SelectionListener() {
public void componentSelected(ComponentEvent ce) {
loader.load();
}
});
panel.addButton(load);
//this.addButton(load);
add(panel);
//add(table);
//loader.load();
}

llusetti
2 Jul 2008, 4:30 AM
I'm facing the same problem, a table inside a panel with FitLayout but table isn't fitted and sisplay scrollbars only if I specify a fixed height.

Any solution even in SVN Repo ?

Luca

gslender
2 Jul 2008, 5:00 AM
try
table.setAutoHeight(true);

llusetti
2 Jul 2008, 5:25 AM
I got no luck mixing the various comination FitLayout with and without setAutoHeight, FlowLayout with setAutoHeight (no scrollbars on the ContentPanel)...

Can we have a working piece of code showing a Table with scrollbar in a FitLayout ContentPanel?

Thanks for the help

Luca

gslender
2 Jul 2008, 12:59 PM
post a code snippet that does what you want and I'll have a look at what might be wrong... make sure it is complete from onModuleLoad compiles without other classes I wouldn't have

llusetti
3 Jul 2008, 12:16 AM
I've found a working solution for my scenario


package com.zensistemi.test.client;

import java.util.ArrayList;
import java.util.List;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Viewport;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
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.table.TableItem;
import com.extjs.gxt.ui.client.widget.toolbar.TextToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.user.client.ui.DeckPanel;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;

public class TestModule implements EntryPoint {

public void onModuleLoad() {

Viewport viewport = new Viewport();
viewport.setLayout(new FitLayout());

ContentPanel cp = new ContentPanel(new FitLayout());
cp.setHeaderVisible(false);
cp.setBorders(false);

ToolBar tb = new ToolBar();
tb.add(new TextToolItem("Test"));
cp.setTopComponent(tb);

ContentPanel nestedCP = new ContentPanel(new FitLayout());
nestedCP.setHeaderVisible(false);
nestedCP.setBorders(false);
nestedCP.setBodyBorder(false);

List<TableColumn> columns = new ArrayList<TableColumn>();

TableColumn col = new TableColumn("Col A", 40);
columns.add(col);

col = new TableColumn("Col B", 1);
columns.add(col);

col = new TableColumn("Col C", 40);
columns.add(col);

TableColumnModel cm = new TableColumnModel(columns);
Table tbl = new Table(cm);
tbl.setBorders(false);


for(int i = 1;i<100;i++) {
TableItem item = new TableItem(new Object[3]);
item.setValue(0, "A" + Integer.toString(i));
item.setValue(1, "B" + Integer.toString(i));
item.setValue(2, "C" + Integer.toString(i));
tbl.add(item);
}

nestedCP.add(tbl);
//DeckPanel deck = new DeckPanel();
//deck.add(nestedCP);
//cp.add(deck);
cp.add(nestedCP);
viewport.add(cp);
RootPanel.get().add(viewport);
}

}
The only problem I have now is putting a standard GWT DeckPanel between my nestedCP and the cp. If you try to uncomment


DeckPanel deck = new DeckPanel();
deck.add(nestedCP);
cp.add(deck);and comment out

cp.add(nestedCP);i get a Java com.google.gwt.core.client.JavaScriptException. Any clue about what i'm doing wrong ?

Luca

llusetti
3 Jul 2008, 12:28 AM
Ok i Solved it myself :D using a CardPanel instead of the GWT DeckPanel


CardPanel deck = new CardPanel();
deck.setLayout(new FitLayout());
deck.add(nestedCP);
deck.setActiveItem(nestedCP);

Now everythings works like a charm.

Luca