Skip to Content
0

How to get model from the app descriptor file and iterate the model?

Dec 17, 2016 at 02:24 AM

107

avatar image

Hi all,

I am using SAP Web IDE and I have two json files and configured them in app descriptor as show below.

I want to get the model from app descriptor and iterate through JSON model and display data in a table from second.json file where Category1 is not equal to “0000” and category2 and category3 is equal to “0000” using first.json.

For the json two files “Type” property is common.

Please suggest me the idea and any help will be appreciated.

Manifest.json
...
"sap.ui5": {
		"_version": "1.1.0",
		"rootView": {
			"viewName": "com.test.ui5.view.Products",
			"type": "XML"
		},
		"dependencies": {
			"minUI5Version": "1.30.0",
			"libs": {
				"sap.ui.core": {},
				"sap.m": {},
				"sap.ui.layout": {}
			}
		},
		"contentDensities": {
			"compact": true,
			"cozy": true
		},
		"models": {
			"i18n": {
				"type": "sap.ui.model.resource.ResourceModel",
				"settings": {
					"bundleName": "com.test.ui5.i18n.i18n"
				}
			},
			"first": {
				"type": "sap.ui.model.json.JSONModel",
				"uri": "model/first.json"
				
			},
				"second": {
				"type": "sap.ui.model.json.JSONModel",
				"uri": "model/second.json"
				
			}
		
		},
		"resources": {
			"css": [{
				"uri": "css/style.css"
			}]
		}
	}
First.json
{
"Type":"A",
 "Category1":"0001",
 " Category 2":"0000",
 " Category 3":"0000",
},
{
"Type":"B",
"Category1": "0002",
" Category 2":"0000",
" Category 3":"0000",
}
... and so on..

Second.json:
{
"Type":"A",
"itemno": "2010",
" itemname":"Sugar",
},
{
"Type":"B",
"itemno": "2010",
" itemname":"Sugar",
} … and so on

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Jun Wu Dec 17, 2016 at 01:55 PM
0

in your controller, this.getOwnerComponent().getModel("first")

Share
10 |10000 characters needed characters left characters exceeded