Is it possible to add DockLayoutPanel inside another panel other than the RootLayoutPanel?
If so, how would you do it?
I attempted to add it inside HTMLPanel, and only north of the DockLayoutPanel shows.
Then I tried it inside LayoutPanel, it failed again.
I thought it would have work for LayoutPanel because RootLayoutPanel is a subclass of LayoutPanel.
Any answers welcome.
Thanks,
DockLayoutPanel is a RequiresResize widget, so either you put it inside a ProvidesResize widget (any so called layout panel) or you give it an explicit size.
See the Using a LayoutPanel without RootLayoutPanel section in http://code.google.com/webtoolkit/doc/latest/DevGuideUiPanels.html#Recipes
Related
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.
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.
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
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.
I was trying some examples with LayoutPanel in GWT. I tried to place a layoutpanel (with size 100%,100%) onto a ScrollPanel that in turn is attached to the rootlayoutPanel. Though the height I have assigned is 100%, it is not showing the layoutpanel to be filled in the rootlayoutpanel. Even if I add a widget to the layoutpanel, its not visible in the designer's view. I could view them by dragging explicitly the layoutpanel on the designer view. But, this would ultimately force the size to be in pixels. why am I finding this behaviour? below is the code:
RootLayoutPanel rp = RootLayoutPanel.get();
LayoutPanel lp = new LayoutPanel();
lp.setSize("100%","100%");
ScrollPanel sp = new ScrollPanel(lp);
rp.add(lp);
with this code, I could see the layoutPanel only as a line. I couldn't see the area (box) covered by Layoutpanel. If I try to manually change the height by dragging, it automatically changes the height of the layoutpanel to pixels:
lp.setsize("100%","500px");
why am I seeing this behaviour? Is there any explanation??
Layout panels can be tricky. LayoutPanels are basically absolute panels, which are intended for full page web apps. To make it work all panels from the root panel down (or from the panel where resize is called and has a fixed size) must have RequiresResize. In your case (besides the err in your example where you add lp instead of sp to the rootpanel, but I assume you intended sp to be added), you put a non LayoutPanel between the RootPanel and the LayoutPanel, this breaks the layout flow and thus the LayoutPanel lp can't be automatically resized. The LayoutPanel will get no height/width.
However, using a ScrollPanel together with LayoutPanels isn't going to work.The whole idea of a LayoutPanel is to derive it's size based on it's parent size, but inside a ScrollPanel the size isn't related, so the size of a LayoutPanel can't be set.