cancel
Showing results for 
Search instead for 
Did you mean: 

Binding of data on UI with model

Former Member
0 Kudos

Hi,

I have created a table on my UI to hold the data from the backend.

I used a odata read service to get this data.

I have enabled the defaultBindingMode to TwoWay.

Code snippet :

          var oModel = new sap.ui.model.odata.ODataModel(

//                                     

                    "proxy/http/spwdfvm1820.wdf.sap.corp:1080/sap/opu/odata/sap/ZPAL_SERVICE/",

                                                            false );

          oModel.setDefaultBindingMode("TwoWay");

          oTable.setModel(oModel);

          oTable.bindRows("/PF_ROOTS");

The issue now : 

Now, I am trying to update data on my UI(it is an editable table) and send the request to the backend for an update.

I am facing issues with the data binding with the UI and Model.

I have 4 rows in my table, and I am trying to update all 4 rows. The first row that gets the update retains the change, while the others are unable to.

Could you kindly let me know of how I could have the changed data persist on my UI which inturn will ensure it on the model, when the call goes to the backend.

Let me know if I have made myself clear.

Thanks and regards,
Pallavika.

 

 

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

What if i want to add a new row in the UI table, sorry but i feel this question is related here may be helpful for others also what should i do if in the same case on button click i want to add a complete record in the UI Table and after adding several records i want all them to be save on button click please advise me too

former_member182048
Active Contributor
0 Kudos

Hi Pallavika

Below is the documentation for the Experimental Two Way Binding

https://sapui5.hana.ondemand.com/sdk/docs/guide/ODataWrite.html#ExperimentalTwoWayBinding

I have not used this technique for a while, so i will go off what the current documentations says

The Two Way binding mode enables the application to update values of a single collection entry without triggering an immediate change request. Create and delete operations are not collected can be called by the application as described above.

If the Two Way binding mode is enabled the setProperty function of the OData model is called automatically to update the value in the specified entry upon user input. If an update to a property of another entry is performed and there is already an update to an existing entry pending a rejectChange event is fired and no change to the property value will be stored in the model.

Looking at the code for setProperty it backs this up

*  Note: Only one entry of one collection can be updated at once. Otherwise a fireRejectChange event is fired.

Are you expecting the 4 changes to be collected as batch operations and used in a $batch call on submitChanges()?

I know that is what i expected when i first tested this feature.

Cheers

JSP

Former Member
0 Kudos

Hi JSP,

Thanks for your reply ! So does it now mean that if I would want to update 4 rows at a time on my table on the UI , this would not be possible ? Kindly clarify .Yes you are right with what i expected, I wanted all my 4 updated and to be sent to backend for a batch update.

Regards,

pallavika.

former_member182048
Active Contributor
0 Kudos

Hi Pallavika,

So does it now mean that if I would want to update 4 rows at a time on my table on the UI , this would not be possible?

Currently it is not possible to update 4 rows in a single operation using the "Experimental Two Way Binding" feature.

It is possible to update 4 rows in a single operation using ODataModel.addBatchChangeOperations, to do this with a table you will need to write your own code.

Cheers

JSP

daniel_rothmund
Participant
0 Kudos

Hi John ,

I have the problem that the user must change many data in different entries . And I use the method setproperty for this. And now the problem I try to send changes back to the gateway with submit changes. But only the first entry will be send .

I saw in the debugger that the event fireRejectChange is fired.

Did you know any solution to many changes in the ui of different entries and then send it back to server ?

Regards

Daniel

Former Member
0 Kudos

Hi Daniel,

here's a blog post which explains how to use the batch operations of a ODATAService to post several changes at once to the ODATA-Service:

Greets,

ben