on 03-28-2023 12:39 PM
Hello Experts
I am currently developing a SAPUI5 webapp for time evaluation. I am getting the data from the backend system, and it's being stored in an OData model. How can I copy that data into a JSON model (for filtering purposes)?
I have the following code:
onInit: function () {
debugger;
const oTable = this.getTable();
const oItems = oTable.getBindingInfo("items").template;
oTable.unbindAggregation('items');
const oModel = this.getView().getModel();
const oModelJSON = new sap.ui.model.json.JSONModel();
oModel.read('/EmployeeSet', {
success: function (oData, response) {
oModelJSON.setData(oData);
oTable.setModel(oModelJSON, 'JSONModel');
oTable.bindItems(
'/EmployeeSet',
oItems
);
},
error: function (oError) {
console.log(oError);
}
});
this.getView().setModel(oModelJSON);
const oDatePicker = this.getView().byId('datum-auswertung');
const sFormattedDate = this.formatDate('dd.MM.yyyy', new Date());
oDatePicker.setValue(sFormattedDate);
}
I think you got it, but it looks like the binding to your table is not correct. 2 quick things. If you are using sap.ui.table you can try bindRows instead, but if you are using sap.m.Table then you are good. Second thing is, you are naming your model so you would have to specify the name of the model in the binding, so instead of /EmployeeSet try JSONModel>/EmployeeSet.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
11 | |
8 | |
8 | |
6 | |
6 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.