GWT DataGrid automatic height - gwt

I'm trying to insert a gwt datagrid in my application. If i set a static height (500px) everything works nice. But i want to make the dataGrid auto adjust to screen size. With height 100% i get a blank screen.
i've also tried to put the datagrid into a resizeLayoutPanel with the same results.
any tips?

All RequiresResize widgets should be given an explicit size, or be added to ProvidesResize widgets (up to a RootLayoutPanel or a ProvidesResize widget with an explicit size; the only exception is ResizeLayoutPanel which doesn't implement ProvidesResize because it couldn't honor the contract for its header and footer widgets, but it definitely honors it for the center widget).
So the question is: where did you add your DataGrid and/or ResizeLayoutPanel?

Thomas Broyer is correct. Nonetheless I found something of interest concerning the DataGrid (it does not happen in CellTable).
If you are using a DeckPanel and if you are creating the DataGrid on a hidden Panel of this DeckPanel, than the data of the DataGrid will not be visible if you show the panel of the DataGrid.
I found only one workaround: call addDataDisplay of your DataProvider "after" the panel was made visible.

Related

Resize the screen in GWT

I am developing a GWT Web application and I would like to include the resize capability into the container. For that, I am implementing a combination of Vertical and Horizontal Panels within a FlowPanel which is resizable. Well, the code for the resize method is the following:
Window.addResizeHandler(new ResizeHandler() {
#Override
public void onResize(ResizeEvent event) {
flowPanel.setHeight(event.getHeight()+"px");
flowPanel.setWidth(event.getWidth()+"px");
}
});
However, when I change the size of the windows, the size of the web elements does not change. Do you know how to implement it?
Thank you very much in advance!!!
You may want to review your layout solution. There are very few cases when you need to use a ResizeHandler. Typically, you can achieve a desired layout either by using a LayoutPanel (or Horizontal/Vertical panels) that automatically resize with the window, or by using CSS. Then your layout will respond well to any changes in a browser window, and you don't need to write any code for that to happen.
EDIT:
In order for a widget to resize automatically, the parent widget must implement ProvidesResize, and the child widget must implement Resizable. FlowPanel does not implement either. Once you use it, the chain of resizing events is broken.
Typically, I use a LayoutPanel for my outmost container. It occupies the entire browser window when added to the RootPanel, and it adjusts with the Window. Vertical and Horizontal panels are similar.
use,
window.getClientWidth();
window.getClientHeight();
Based on your component size you can -/+ px and use.

What is the logic of DockPanel & DockLayoutPanel in GWT? I'm confused

look at this DockPanel http://gwt.googleusercontent.com/samples/Showcase/Showcase.html#!CwDockPanel
& it's code:
dock.add(new HTML(constants.cwDockPanelNorth1()), DockPanel.NORTH);
dock.add(new HTML(constants.cwDockPanelSouth1()), DockPanel.SOUTH);
dock.add(new HTML(constants.cwDockPanelEast()), DockPanel.EAST);
dock.add(new HTML(constants.cwDockPanelWest()), DockPanel.WEST);
dock.add(new HTML(constants.cwDockPanelNorth2()), DockPanel.NORTH);
dock.add(new HTML(constants.cwDockPanelSouth2()), DockPanel.SOUTH);
Is it similar to the BorderLayout in Java? or it is different?
How to set layout using DockLayoutPanel in UiBinder for the below picture:
Why don't they add the Center? I am confused, also how to set docklayout for the above picture in UiBinder?
Diffrences between DockPanel and DockLayouPanel
DockLayoutPanel
A panel that lays its child widgets out "docked" at its outer edges,
and allows its last widget to take up the remaining space in its
center. This widget will only work in standards mode, which requires
that the HTML page in which it is run have an explicit
declaration.
DockPanel
A panel that lays its child widgets out "docked" at its outer edges,
and allows its last widget to take up the remaining space in its
center. This widget has limitations in standards mode that did not
exist in quirks mode. The child Widgets contained within a DockPanel
cannot be sized using percentages. Setting a child widget's height to
100% will NOT cause the child to fill the available height.
If you need to work around these limitations, use DockLayoutPanel
instead, but understand that it is not a drop in replacement for this
class. It requires standards mode, and is most easily used under a
RootLayoutPanel (as opposed to a RootPanel).
DockLayoutPanel is similar to BorderLayout.
To add something in center use add with no params:
dockLayoutPanel.add(widget);
This will take all remaining space.
The center widget should be added last. Otherwise you get an exception.
The Layout you want to create can't be done with just one DockLayoutPanel.

GWT ScrollPanel with Horizontal SimplePanel

I'm trying to implement a scrollPanel within a Horizontal Panel.
I read this post
GWT Horizontal panel with horizontal scrolling
The answer seems great, however I'm wondering if ravi wrapped his simple panel with a scroll Panel or vice versa.
Basically I wanted to know how the panels were nested within each other?
A scroll panel is nothing special - it's just a DIV element with some CSS set on it. That's what the answer to the other question means, as a SimplePanel is simply a Widget that appears as a DIV.
So what the other answer did was create a scrolling widget by:
Creating a SimplePanel as the content container
Set some CSS with the overflow-x attribute to the SimplePanel
Setting the content will now have a horizontal scroll bar (due to the CSS attribute).
If you prefer a more direct way of doing this check out UiBinder. Using it you can combine widgets/CSS/HTML elements in a form closer to how the browser renders your UI. So for example you can create a DIV with the required CSS to achive a scrolling container.

GWT: DataGrid - set height 100% not rendering properly

I am working with layout panels and datagrid. When I set the datagrid height to 100%, Grid is not rendering. My panel hierarchy looks like the following image
Am I doing it properly or I messed up the panel hierarchy???
Parent panel is the simple layout panel, inside that I have split layout panel -> scrollpanel -> datagrid
DataGrid requires to be put in a LayoutPanel or Panel that implements the ProvidesResize interface to be visible. ScrollPanel implements that interface.
Furthermore this chain of LayoutPanels from your DataGrid up to your root element/panel has to be unbroken. That seems to be the case in your panel hierarchy.
Finally you have to use the RootLayoutPanel instead of the RootPanel to add your LayoutPanels.
So did you make sure that you add your SimpleLayoutPanel to the RootLayoutPanel ?
In my case it was caused by this:
DataGrid rows not visible in second tab of TabLayoutPanel

How do you get GWT 2.0 to accept clicks on two different Widgets added to a LayoutPanel?

Using GWT 2.0 I have an entry point that adds two Widgets to a LayoutPanel which in turn is added to the RootLayoutPanel. The Widgets both handle click events and have click events registered to them. The problem is that only the last widget added to the LayoutPanel can actually be clicked. Switch the order in which the widgets are added switches the widget that works. Add mroe widgets and still the only you can click is the last one added to the LayoutPanel.
Any idea why this is? Is there any reasoning behind the behaviour, or have I missunderstood what is happening under the covers? How do I gat all widgets in the LayoutPanel to accept events? Should I be using another panel class?
I'm not too bothered if the LayoutPanel prevents anything below it from being clicked, but want all Widgets added to it to be clickable.
Stupid Boy! (said in the voice of Captain Mainwaring)
There is no problem having two Widgets on a LayoutPanel accepting clicks. But if you adjust the Widgets' size by manipulating their elements' styles directly then the containing element created by the LayoutPanel will still cover the whole screen. In effect the last Widget added always covered everything else.
GWT school: D- Must try harder. Easily distracted...