Toggle Visibility of a Sidebar Element

119 views
Skip to first unread message

Manuel

unread,
Nov 6, 2012, 4:01:55 PM11/6/12
to google-we...@googlegroups.com
Hey,

I try to toggle the visibility of a Element. But I dont get a resizing done :(

I use a DockLayoutPanel:
In the WEST I got a "Sidebar". In the CENTER I got a Frame...

I made the Sidebar invisible via: DOM.setStyleAttribute(SideBar.getElement(), "display", "none");

But the CENTER dont take the free space. (DOM.setStyleAttribute(CenterFrame.getElement(), "position", "relativ"); didnt worked)



Via Firebug i found out, that the center is wrapped in a div-tag that I cannot manipulate.

So anyone know whats the propper way, to make the Sidebar visible/invisible ?

Help is much appreciated.

Thanks in advanced.

Regards


Alberto Mancini

unread,
Nov 6, 2012, 4:44:57 PM11/6/12
to google-we...@googlegroups.com
Hi,
actually this should work

class MyDockLayoutPanel extends DockLayoutPanel {

        public MyDockLayoutPanel(Unit unit) {
            super(unit);
        }
  
        public void resizeWidget(Widget w, double newSize) {
           
            //XXX ensure it is a widget added to this this layoutpanel
 
            LayoutData ld = (LayoutData) w.getLayoutData();
            ld.size = newSize;
            forceLayout();
        }
               
    }


use newSize=0 to hide.

I remember I used somewhere a similar code but i never really found why LayoutData has been left protected in DockLayoutPanel
and if this approach has to be avoided.

Ciao.







--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/JKvAUUjMYO4J.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Andrea Boscolo

unread,
Nov 6, 2012, 7:09:22 PM11/6/12
to google-we...@googlegroups.com
Actually DockLayoutPanel implements AnimatedLayout thus it has direct animation support.
You simply need to use setWidgetSize(widget, size) and call animate() (if necessary).
Or even simpler use setWidgetHidden(widget) with gwt >= 2.5.

Manuel

unread,
Nov 7, 2012, 2:29:24 PM11/7/12
to google-we...@googlegroups.com
Hey,
thanks alot, that works well and is pretty easy.

Regards Manuel
Reply all
Reply to author
Forward
0 new messages