Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8545

Re: OData model binding read / write

$
0
0

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


Viewing all articles
Browse latest Browse all 8545

Trending Articles