GWT ScrollPanel with Horizontal SimplePanel - gwt

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.

Related

Strange issue when I using GtkScrolledWindow in glade

I want to wrap a listbox widget into a scrolled widget, then I find the GtkScrolledWindow, however, I could not drag and drop a GtkListBox into GtkScrolledWindow. I also tried right click the GtkListBox, select Add Parent then Scrolled Window like the following snapshot.
But, I could make it work by manual modify the glade ui file.
So I want to know Why and How to do it in glade.
José Fonte's answer is right, I need to wrap the content into a viewport first, then make the viewport as a child of scrolledWindow.

GWT ScrollPanel headers

I just started looking into GWT today, and would like to poke the experts on how to achieve a certain result.
I need to have a scrollPane with headers, similar to swing's JSCrollPane. For those not familiar with it, a JScrollPane can have either a row or a column header. For now let's focus on one with row headers. The main component would be a Canvas in which I would draw a view based on the position of the scroll bars for the scroll pane
In the case of a row header, this header can be filled with components stacked vertically. The vertical scroll bar scrolls the vertical components stack, as well as the main client area. The horizontal scrollBar scrolls horizontally the main area, but not the row header, which remains always visible.
As far as I can tell the standard GWT ScrollPanel doesn't support headers directly.
First of all, is there a component providing this functionality already in standard GWT? I looked at the Cell components, which might work for column headers, but don't seem to work for row ones. Is there such a component in some third-party (possibly open source) library?
If I had to implement this, what approach would you suggest?
I considered creating just a VerticalPanel for the row header, a Canvas as large as the view for the main component. I can draw the content on the canvas upon scroll changes, but I'm not sure how to make only a portion of the VerticalPanel show (viewport).
I also considered wrapping just the vertical panel in a ScrollPane, have a separate horizontal scrollbar to (virtually) scroll around the canvas horizontally, but in this case the vertical scroll bar appears between the header and the canvas, which is not what I want.
Thanks!
Use a LayoutPanel with two children: FlowPanel (or a Label) to represent your header (vertical or horizontal) and a ScrollPanel. Position these widgets next to each other.
LayoutPanel layoutPanel = new LayoutPanel();
Label header = new Label("My header");
ScrollPanel scrollPanel = new ScrollPanel();
layoutPanel.add(header);
layoutPanel.add(scrollPanel);
layoutPanel.setWidgetLeftWidth(header, 0, Unit.PX, 36, Unit.PX);
layoutPanel.setWidgetLeftRight(scrollPanel, 36, Unit.PX, 0, Unit.PX);
LayoutPanel implements ProvidesResize, so it will give the available space to ScrollPanel. Make sure that LayoutPanel itself is a child of a widget that implements ProvidesResize, or set its size explicitly.
If you only support modern browsers, you can achieve the same result with a flexbox layout model. Set "flex-grow: 0" on a header, and "flex-grow: 1" on a ScrollPanel. The advantage is that you can turn the same component into vertical or horizontal by changing just one CSS property. And it's more responsive and easier to adjust to different screen sizes.

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

GWT DataGrid automatic height

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.

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...