on 06-27-2014 4:38 PM
Dear Experts,
For an internal training in my company I am trying to make a prototyp using Northwind OData service. As you would now you can only read data using Northwind service. I want to show examples about deleting and adding items. What would the best approach to do this? Deleting and adding should be of course only faked in the UI and not persisted. For example like in Approve Purchase Orders example. Can I clone the model and work on it? I realized that I couldn't even call oModel.setData using Northwind. I would be happy about every input and suggestions.
Thanks and Regards,
Koray
Hi Koray,
For training purpose I will suggest you,
For Read Operation:
Use Northwind service for getting data into JSON Model. Keep binding mode for JSON model as "TwoWay"
var oModel = new sap.ui.model.json.JSONModel();
oModel.setDefaultBindingMode("TwoWay");
For Delete Operation:
Take the JSON model data into an array.
var data = oModel.getData();
You can remove records from array using splice() method.
data.splice(index,1); // You may need to use data.value.slice when using Northwind service
For Insert Operation:
You can insert a record into array using push() method.
data.push('Tom');
As we have declared our model binding mode as "TwoWay", means from model to view and vice versa, whatever operation you will perform on array it will take effect on model data as well(locally).
Hope it will help you.
Regards,
KK
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.