Tuesday, May 29, 2012

Using LayoutPanel without RootLayoutPanel

This one is simple but could cause you some headaches when you try to test some components like DataGrid. Basically the DataGrid needs to be used inside some GWT Layout Panel like for example LayoutPanel or DockLayoutPanel and so on, which also requires the use of RootLayoutPanel. There are of course cases where you are not able to use the RootLayoutPanel but the RootPanel. You may wonder that nothing is shown on the screen, when you try this. To fix this you need to se the panel size explicitly, otherwise the panel is there but does not expand to show the content inside. For example in my case:

DataGrid<Contact> table = new DataGrid<Contact>();
LayoutPanel panel = new LayoutPanel();
panel.setSize("30em", "10em");
panel.add(table);
RootPanel.get("yourId").add(panel);



Very easy but don’t forget it!

No comments:

Post a Comment