OPENUI5: Named aggregate binding data not displayed

after reading Multimodal Device Support I tried to implement it. When using a named model, binding occurs but no data is displayed.

//Controller

sap.ui.controller("view.apps.Apps", {

    onInit : function () {
        var oAppsModel = new sap.ui.model.json.JSONModel("model/apps.json");
        this.getView().setModel(oAppsModel, "apps");
    }
});

      

// View

sap.ui.jsview("view.apps.Apps", {

    getControllerName: function() {
        return "view.apps.Apps";
    },

    createContent: function(oController) {

        var oInboxList = new sap.m.List({
            inset: true,
            id: "appsList",
            headerText: "Apps"
        });

        oInboxList.bindItems("apps>/items", function(sID, oContext) {
            return new sap.m.StandardListItem({
                title: '{name}',
                description: '{name}'
            })
        });

        var oPage = new sap.m.Page({
            title: "Apps",
            content: [oInboxList]
        });

        return oPage;
    }
 });

      

//apps.json

{
    "items": [{
        "name": "ABC",
        "view": ""
    }, {
        "name": "DEF",
        "view": ""
    }]
}

      

This view creates two empty lists. When I change the model to an unnamed model, and I update the BindPath to / items, the List is populated correctly and the values ​​are displayed. Any ideas on what is wrong with my coding? I would really like to use the named models.

+3


source to share


1 answer


OK, just re-read the documentation. When using a named model, bindings require the ALL bindings prefix with the named model name.



oInboxList.bindItems("apps>/items", function(sID, oContext) {
        return new sap.m.StandardListItem({
            title: '{apps>name}',
            description: '{apps>name}'
          })
    });

      

+8


source







All Articles