I need some help with Google web toolkit to make a vertical menu with expanding submenu items.
I want to create a vertical menu that woks like the left menu on the showcase of GWT
I tried this:
VerticalPanel vertpanel = new VerticalPanel();
MenuBar menubar = new MenuBar(true);//set to true so its set to vertical alignment
MenuBar subbar = new MenuBar(true);
MenuBar subbar2 = new MenuBar(true);
subbar.addItem("Fist item of submenu1", new AddEmployeeCommand());
subbar.addItem("Second item of submenu1", new AddEmployeeCommand());
subbar2.addItem("First item of submenu2", new AddEmployeeCommand());
subbar2.addItem("Second item of submenu2", new AddEmployeeCommand());
menubar.addItem("sub 1", subbar);
menubar.addItem("sub 2", subbar2);
vertpanel.add(menubar);
RootPanel.get().add(menubar);
But that doesn’t work because the menu items won’t expand to show their subitems. Although it works when I make it a horizontal menubar but that’s not what I want.
You’ll need to use
DisclosurePanels in order to achieve that.Check it out in the GWT showcase.