PDA

View Full Version : Horizontal Menu using MenuModel not working



rakesh.tbt
5 Jan 2012, 4:55 AM
Hi all,
Sharing with you the piece of code i am working on now to create a horizontal menu with submenu. I was able to create a tree menu using TreePanel but facing some issue in changing that to Horizontal menu using menubar.
Below is my MenuView file which is extending View:


ContentPanel createReportMenu() {


ContentPanel menu = new ContentPanel();


menu.setAnimCollapse(false);


menu.setHeading("Report");





TreeStore<MenuModel> store = new TreeStore<MenuModel>();


store.add(new MenuModel("Last week", MenuModel.REPORT_TYPE), false);


store.add(new MenuModel("Last month", MenuModel.REPORT_TYPE), false);


store.add(new MenuModel("Last year", MenuModel.REPORT_TYPE), false);





TreePanel<MenuModel> tree = new TreePanel<MenuModel>(store);


tree.getStyle().setLeafIcon(IconHelper.createStyle("tree-folder"));


tree.setDisplayProperty("name");


tree.setAutoSelect(true);


tree.getSelectionModel().addSelectionChangedListener(


new SelectionChangedListener<MenuModel>() {





@Override


public void selectionChanged(SelectionChangedEvent<MenuModel> se) {



MenuModel f = (MenuModel) se.getSelection().get(0);



Dispatcher.get().dispatch(AppEvents.MenuSelected, f);



}



});





menu.add(tree);



return menu;



}




The above code is working and it shows the Menu in tree format.MenuModel file is extending BaseTreeModel. I want the same menu to be shown in horizontal menu bar. Please provide the input how to make those change. Thanks!!

smiletolead
6 Jan 2012, 4:48 PM
Your question is not clear. You are using tree and you are expecting it to behave like menu. It is not clear what do you mean by horizontal menu. There is MenuBar in GXT if you are looking for similar to that.