Skip to Content

Uncaught TypeError: Cannot read property 'getProperty' of undefined - Json Model - XML View

I have created a worklist app with my data in a local json file. I am able to get the data in master page.

detail-view.png

On navigation, I am getting the error message as uncaught type error.

error-message.png

The master controller code goes like this

 onListPress : function(oEvent) {
            var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
            var oItem = oEvent.getSource();
        
            oRouter.navTo("detail", {
            	ID: oItem.getBindingContext().getProperty("ID")
            });
	    }

In the controller I am getting value for oItem. For example if i click on first item of the table, it returns table_0-0

Here table_0 is the id of the table.

I have defined the model in manifest.json file.

"models": {
	"i18n": {
			"type": "sap.ui.model.resource.ResourceModel",
			 "settings": {
			 "bundleName": "sapui5.demo.mvcapp.i18n.i18n"
				}
			},
			"test": {
				"type": "sap.ui.model.json.JSONModel",
				"settings": {},
				"uri": "service/data.json"
	
			}
		}

Please help me to resolve the error.

Thanks in Advance,

Janani

detail-view.png (10.8 kB)
error-message.png (18.8 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Oct 27, 2017 at 05:59 AM

    Hi,

    I have resolved the error.

    Since I am using local json model. In the controller code, I have given my model name in getBindingContext("test") function. It works fine.

    ID: oItem.getBindingContext("test").getProperty("ID")
    Add comment
    10|10000 characters needed characters exceeded