I need to show a list in a table. This list shall be filtered at client-side, and because of that I need to copy the OData model into a local JSON model.
The OData model looks like this:
OData model
I am able to show the "/ZcountWerksSet" list (from the OData model) inside a table using this code:
oSearchTable.bindAggregation("items", "/ZcountWerksSet", new sap.m.ColumnListItem({
cells : [
new sap.m.Text({
text : "{Name1}"
}),
new sap.m.Text({
text : "{Werks}"
})
]
}));
Then I am copying this into a JSON model like this:
var oModel = this.getView().getModel();
var oModelJson = new sap.ui.model.json.JSONModel();
oModel.read("/ZcountWerksSet", {
success: function(oData, response) {
oModelJson.setData(oData);
sap.ui.getCore().setModel(oModelJson, "oJSONModel");
alert("Success!");
},
error: function(response) {
alert("Error");
}
});
Then the model looks like this
JSON Model
Trying to show the same list (from JSON model this time), in a table using the following code is NOT working:
oSearchTable.bindAggregation("items", "{oJSONModel>/}", new sap.m.ColumnListItem({
cells : [
new sap.m.Text({
text : "{oJSONModel>Name1}"
}),
new sap.m.Text({
text : "{oJSONModel>Werks}"
})
]
}));
How can I show the same data in the table, but only from the JSON model this time?
Any ideas what I'm doing wrong?
You need to adopt your binding path to
{oJSONModel>/results}
as a different binding implementation is used for a JSONModel.