PDA

View Full Version : Grid that fills with contentpanel.



dimitre
4 May 2012, 7:35 AM
I am trying to create a grid that fills the width of a ContentPanel when brownser is resizing.
Any ideas?

Here is my code:

GroupingView view = new GroupingView();
view.setEmptyText("No Data");
view.setForceFit(true);


grid = new Grid<CampaignResultListGrid>(store, cm);
grid.setView(view);


new QuickTip(grid);
grid.disableTextSelection(false);
grid.setColumnLines(true);
grid.setStripeRows(true);
grid.ensureDebugId("awrgrid");
grid.setAutoWidth(true);
initListener();

mainContent = GWT.create(ContentPanel.class);
mainContent.setFrame(true);

mainContent.layout(true);
mainContent.setLayout(new FitLayout());
mainContent.setTopComponent(initFilterPanel());
mainContent.add(grid);


mainContent.setHeight(Window.getClientHeight() - 98);
mainContent.setWidth("100%");
mainContent.ensureDebugId("panelgrid");
return mainContent;

Thanks.

shingocat
9 May 2012, 4:49 AM
why not use Viewport to be the top container.

Viewport viewport = new Viewport();
ContentPanel cp = new ContentPanel();
Grid grid = new Grid(store,columnModle);
cp.add(grid);
viewport.add(cp)

dimitre
9 May 2012, 6:07 AM
Thanks, it's working now.

I have just forgotten to tell you that i am a new be in GXT.

sven
9 May 2012, 10:59 AM
To add some small hint. In the code snippet are two FitLayouts missing. Both viewport and the contentpanel should have a FitLayout set to make the grid resize correctly.