在SAPUI5

时间:2017-03-14 05:29:43

标签: sapui5

我尝试从第一页到第二页点击列表,从一个页面导航到另一个页面。当我点击第一页上的列表时,我导航到第二页但在第二页上列表未来。

我通过JSON模型将数据填充到列表中。在第一页上,数据即将到来,但第二页则没有。请帮我找到解决方案。

这是我的第二页控制器....

onInit: function() {
    var model2 = new sap.ui.model.json.JSONModel();
    data1 = [
            {categories: "Laptop Case"},
            {categories: "USB Stick 16 GB"},
            {categories: "Webcam"},
            ];
    model2.setData({shopping1:data1});
    sap.ui.getCore().setModel(model2,'idModel2');
},

这是我第二页的视图部分......

createContent : function(oController) {
    return new sap.m.Page('idMasterpage1',{
        showHeader:true,
        showNavButton:true,
        navButtonPress:function(oControlEvent){
            var app=sap.ui.getCore().byId('idSplitApp');
            app.to('idmasterPage1');
        },
        content: [
                    new sap.m.List('MainList1',{
                    headerText: 'ACCESSORIES',
                    path:'/shopping1',
                    items: {
                          template:new sap.m.ObjectListItem("idListtest",{
                              title:'{categories}',
                              type:"Navigation",  
                           }),  
                    },
                    })
        ]
    });
}

1 个答案:

答案 0 :(得分:0)

尝试下面应该有效的代码:

onInit: function() {
    var model2 = new sap.ui.model.json.JSONModel();
    data1 = [
            {categories: "Laptop Case"},
            {categories: "USB Stick 16 GB"},
            {categories: "Webcam"},
            ];
    model2.setData({shopping1:data1});
    this.getView().setModel(model2,'idModel2');
},

createContent : function(oController) {
    return new sap.m.Page('idMasterpage1',{
        showHeader:true,
        showNavButton:true,
        navButtonPress:function(oControlEvent){
            var app=sap.ui.getCore().byId('idSplitApp');
            app.to('idmasterPage1');
        },
        content: [
                    new sap.m.List('MainList1',{
                    headerText: 'ACCESSORIES',
                    items: {
                          path:'idModel2>/shopping1',
                          template:new sap.m.ObjectListItem("idListtest",{
                              title:'{idModel2>categories}',
                              type:"Navigation"
                           }),  
                    },
                    })
        ]
    });
}