Skip to Content
0
Dec 02, 2022 at 01:22 PM

SAPUI5: How can I show models from manifest.json in ComBox ?

149 Views

Hello,

how can I put the Model (Section "models") in a ComBox ?:

manifest.json

....

"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "versuch1.i18n.i18n"
}
},

"": {
"dataSource": "mainService",
"preload": true,
"settings": {}
},
"MyModel2": {
"dataSource": "Service1",
"preload": true,
"settings": {}
},
"MyModel3": {
"dataSource": "Service2",
"preload": true,
"settings": {}
}

Code:

// file is fully loaded into the JSON model

var aData = that.getView().getModel("Manifest").getData();
var aManifest_sap_ui5 = aData["sap.ui5"];
var aManifest_models = aManifest_sap_ui5["models"];

var oCoMBoxManModels = that.getView().byId("idCoMBoxModelMan");

// hier the problem, cannot read aManifest, ist not array ?

for (var i = 0; i < aManifest_models.length; i++) {
var newItem = new sap.ui.core.Item({
key: aManifest_models[i] ,
text: aManifest_models[i]
});
oCoMBoxManModels.addItem(newItem);
}

// hier the problem, cannot read aManifest, ist not an array ?

grafik.png

How can I loop over the first element "", "MyModel2" , "MaModel3" .... ?

(I don't "know" nams of models, its should be get dynamic)

Thanks !

Greg

Attachments

grafik.png (21.3 kB)