on ‎2021 Apr 22 3:44 AM
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'.
Request clarification before answering.
Hello,
as you can see in the sapui5 documentation(screenshot below), two-way binding ist not supported for list binding but for property binding.
Best regards,
Kevin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
what business function you are trying to achieve?
odatamodel is just different from jsonmodel.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
| User | Count |
|---|---|
| 8 | |
| 7 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.