Json map for menus in Openui5

In w2ui, I can map json to the sidebar http://w2ui.com/web/demos/#!sidebar/sidebar-1 Can I do this in openui5?

I need the same result.

Obviously, I don’t need a tree, but a list of elements that scroll to the right if I click on an element (and render the list of submenus) and move left if I press the back button (and render the menu at the top level), enter image description here

0
json sapui5 w2ui
source share
2 answers

I solved my problem: Each time I click on a menu item, I call this function in the view controller:

//when click on item onPressMenuItem: function(evt) { var selectedItem=evt.getSource().getBindingContext().getObject(); var objAction=getActionWhenPressMenuItem(selectedItem, this.getView().getModel()); console.log(objAction); if(objAction.hasNextSidebar==true){ // sub menu var model = new sap.ui.model.json.JSONModel(); model.setData(objAction.nextSidebar); var oSplitApp=sap.ui.core.Core().byId("splitApp"); var nextView = sap.ui.xmlview("general.master.menuMaster"); nextView.setModel(model); nextView.byId("idPageSidebar").setTitle(selectedItem.text); oSplitApp.addMasterPage(nextView); oSplitApp.toMaster(nextView); }else{ // open operation detail var idDetail =objAction.opDetail; var targetApp = getAppBySelectionId(idDetail); if(targetApp.masterView!=null){//if app has own master sap.ui.getCore().getEventBus().publish("navMaster", "to", { idView: targetApp.masterView }); } if(targetApp.detailView!=null){//if app has own detail sap.ui.getCore().getEventBus().publish("navDetail", "to", { //titleOfDetailPage: selectedItem.text, idView: targetApp.detailView, //idCall: selectedItem }); } } }, 

Each time I create a new menu value on a new page.

0
source share

I think this is possible, but as far as I know, you should do manual labor:

  • Determine if your node has one or more child nodes, and based on this parameter set sap.m.ListType to Navigation or not
  • If your root node (fi, "/items" ) has child nodes (fi, "childs" ), you need to re-link your list to this child path ("/items/<index_of_parent_node>/childs)
  • To get the scroll effect, you probably need to encapsulate the list in sap.m.Page
  • Depending on the level of the node you are in, you need to hide / show the "Back" button and clicking on it, bind your list to the parent path

However, if there is a cleaner, simpler approach, I would also like to hear it!

0
source share

All Articles