cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

oData v2 Model Two-Way binding not updating properties after user inputs in the UI.

0 Likes
2,826

Hello experts, I am currently trying to get my oData model to refresh changes locally after user inputs in my UI. I have a sap.m.List type control directly binded to my v2 Odata Model, and I have set my default binding mode to Two-way by using the following method:

oModel.setDefaultBindingMode(sap.ui.model.BindingMode.TwoWay);

My list control has several Input or editable fields for the user to modify the data belonging to my binded entity, but I haven't been able to successfuly refresh my model to capture those changes in the UI. I am able to retrieve them by using the getPendingChanges() model method:

I suppose I could capture the changes from the array returned by getPendingChanges() and then manually setting them to my model by using setProperty(), but I'm hoping there's a simpler and more effective way to achieve what I need to do.

So far I've tried using refresh() both at model level and at view/control level, but that didn't solve my issue either. I also tried using oModel.updateBindings() but this seems to always return 'undefined'.

Accepted Solutions (0)

Answers (3)

Answers (3)

Kevin_Gottwald
Explorer

Hello,

as you can see in the sapui5 documentation(screenshot below), two-way binding ist not supported for list binding but for property binding. 

Kevin_Gottwald_0-1722347755463.png

Best regards,

Kevin

junwu
SAP Champion
SAP Champion
0 Likes

what business function you are trying to achieve?

odatamodel is just different from jsonmodel.

rohit_singhal
Active Contributor
0 Likes

Hi Pampa,

Looking at your problem statement, it looks like the changes have not been submitted.

There is a method for oData Model called submitChanges. I think once you invoke it, the above issue should resolve.

Alternatively, is there a specific requirement due to which you are not using create/update entry methods in oData Model to create and update entries instead of using it in two-way mode?

Do let me know how these suggestions work out for you.

Best Regards,

Rohit

0 Likes

Hi rohit.singhal, thanks for your answer! I understand submitChanges() is the method you call to send your changes over to the backend service, while what I need to do is for my changes to apply locally in my model so I am able to retrieve them by doing oModel.getData() or getObject() or even getProperty(). I know this works fine if I use JSON models because the twoway binding immediately applies every change made in the UI to my local model but I am trying to replicate that same behavior on a oData v2 model instead.