Need to put a json data like this
{
"marcas":[
{
"__metadata":{
"id":"data id",
"uri":"data url",
"type":"data type"
},
"Codcard":"01",
"Descript":"MasterCard"
},
]
}
Into a select input like this one...
var oSelectMarca = new sap.m.Select({
items: {
path: "marcas",
template: new sap.ui.core.ListItem({
key: '{Kunnr}',
text: '{Descrip}'
}),
templateShareable: true
},
selectedKey: '{Marca}'
});
I'm trying to do it saving this data into a model and then calling it as you can see above,
var oModelListMarcasTarjeta = new sap.ui.model.json.JSONModel();
var marcas = [{
Descrip: "",
Kunnr: ""
}];
var sUrlCard = "data url";
var oDataModelCards = new sap.ui.model.odata.ODataModel(sUrlCard, true);
oDataModelCards.read("dataCollection", {
async: false,
success: function(oData, response) {
$.each(oData.results, function(i, val) {
marcas.push(val);
});
oModelListMarcasTarjeta.setData({
'cards': marcas
});
sap.ui.getCore().setModel(oModelListMarcasTarjeta, "marcas");
}
});
but is not working, any idea what is wrong?
If I set the model direct to the select input, of course works, but for some reason the input doesn't set te value of the selected item in the list.