sapui5统一Shell(sap.ui.unified.Shell)中的导航问题 [英] Navigation Problems in a sapui5 unified Shell (sap.ui.unified.Shell)

查看:112
本文介绍了sapui5统一Shell(sap.ui.unified.Shell)中的导航问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用统一的Shell控件来实现类似Facebook的滑动菜单,并且在其中集成了一个列表,以便可以输入菜单项.这个想法是,当用户单击菜单中的某个列表项时,他将被重定向到新视图.我试图通过使用bus.publish("nav","to" {id:..})来实现它,但是它不起作用. (我已将菜单放在统一外壳的窗帘窗格中)有人可以帮助我吗? 您可以在下面找到视图和控制器的相应代码段.

I have used unified Shell control in order to implement the facebook-like swipe menu and I integrated in it a list so that I can enter menu items. The idea is that when a user clicks on a certain list item in the menu he will get redirected to a new view. I tried to implement it by using bus.publish("nav", "to" {id:..}) but it's not working. (I have put the menu in the Curtain Pane of the Unified Shell) Can anybody help me? You can find below the respective code snippets of the view and controller.

var oListTemplate = new sap.m.StandardListItem({
            title: "{title}",
            icon: "{icon}",
            description: "{description}",
            type: sap.m.ListType.Navigation,
            customData: new sap.ui.core.CustomData({
                key: "targetPage",
                value: "{targetPage}"
            })
        });

        var oList = new sap.m.List({
            selectionChange: [oController.doNavOnSelect, oController],
            mode: sap.m.ListMode.SingleSelectMaster
        });
        oList.bindAggregation("items", "/Menu", oListTemplate);

控制器:

onInit: function() {

        this.getView().setModel(new sap.ui.model.json.JSONModel("model/menu.json"));
       this.bus = sap.ui.getCore().getEventBus();
    },


 doNavOnSelect: function(event){
     if (sap.ui.Device.system.phone) {
            event.getParameter("listItem").setSelected(false);
        }
     this.bus.publish("nav", "to", {
            id: event.getParameter('listItem').getCustomData()[0].getValue()
        });

推荐答案

解决方案:将bus.publish替换为app.to

Solution: Replace bus.publish with app.to

doNavOnSelect: function(event){
    if (sap.ui.Device.system.phone) {
            event.getParameter("listItem").setSelected(false);
        }

    app.to(event.getParameter('listItem').getCustomData()[0].getValue());

    }  

这篇关于sapui5统一Shell(sap.ui.unified.Shell)中的导航问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆