Skip to Content
0
Former Member
Aug 08, 2016 at 10:46 AM

Can't access odata model property in controller

568 Views

Hi,

i'm trying to get a property of my odata model in my controller. But i only get "undefined" returned if i call the getProperty method(). My path strings are correct.

return Controller.extend("controller.StatisticsDashboard", {
        onInit : function() {
            var oModel = this.getOwnerComponent().getModel("flexiForecast");
            var oRequests = oModel.getProperty("/FlexibilityRequests");
           var iCount = oRequests.length;

            this.getView().byId("requestCount").setValue(iCount);
      

"models": {
            "i18n": {
                "type": "sap.ui.model.resource.ResourceModel",
                "settings": {
                    "bundleName": "i18n.i18n"
                }
            },
            "flexiForecast": {
                "dataSource": "FlexiForecast",
                "settings": {
                    "defaultBindingMode": "TwoWay"
                }
            }
        },

Thanks and best regards,

Tobias