更新时间:2023-10-07 11:36:40
既然你有模型名称,你也需要在绑定路径中使用它
As your have the model name, you need to use it in the binding path as well
假设您有以下来自后端的 JSON 数据.
Let say you have the following JSON data from backend.
JSON 数据
{
'cards': [{
'Descrip': "",
'Kunnr': ""
}, {
'Descrip': "ss",
'Kunnr': "asf"
}, {
'Descrip': "fff",
'Kunnr': "asdf"
}, {
'Descrip': "fas",
'Kunnr': "asdf"
}, {
'Descrip': "asdfa",
'Kunnr': "asdfwer"
}]
}
绑定
var oModelListMarcasTarjeta = new sap.ui.model.json.JSONModel();
oModelListMarcasTarjeta.setData({ //for implementation I am setting the data like this
'cards': [{
'Descrip': "",
'Kunnr': ""
}, {
'Descrip': "ss",
'Kunnr': "asf"
}, {
'Descrip': "fff",
'Kunnr': "asdf"
}, {
'Descrip': "fas",
'Kunnr': "asdf"
}, {
'Descrip': "asdfa",
'Kunnr': "asdfwer"
}]
});
sap.ui.getCore().setModel(oModelListMarcasTarjeta, "marcas");
//Use Model name for binding
var oSelectMarca = new sap.m.Select({
items: {
path: "marcas>/cards",
template: new sap.ui.core.ListItem({
key: '{marcas>Kunnr}',
text: '{marcas>Descrip}'
})
}
});