cancel
Showing results for 
Search instead for 
Did you mean: 

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

janani_10
Explorer
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

janani_10
Explorer
0 Kudos

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")

Answers (0)