SAP / openui5

OpenUI5 lets you build enterprise-ready web applications, responsive to all devices, running on almost any browser of your choice.
http://openui5.org
Apache License 2.0
2.96k stars 1.24k forks source link

oData V4 - Binding Issue #3833

Closed AswinDC closed 1 year ago

AswinDC commented 1 year ago

OpenUI5 version:1.96.10

Browser/version (+device/version): Chrome

Any other tested browsers/devices(OK/FAIL):

URL (minimal example if possible):

User/password (if required and possible - do not post any confidential information here):

Steps to reproduce the problem:

  1. Unable to use binding oData V4 in simpleForm while passing the filters as parameters

What is the expected result?

What happens instead?

Any other information? (attach screenshot if possible) f9e9eec9-8206-41b6-908b-e0097df38c75

Trying to pass filter parameters for direct binding of the form elements. And I also have a question here is it possible to change the binding dynamically in controller i want to change the B701 to something else when some action happens.. kindly provide an example

Getting this below error in console: 734ba2f1-a26b-4f9b-a527-701620a960ca

boghyon commented 1 year ago

Is the same issue reproducible also with the latest 1.96 patch number (e.g. https://sdk.openui5.org/1.96.23/) or with the latest OpenUI5 snapshot https://sdk.openui5.org/nightly/? Please share valid steps to reproduce the issue possibly with an OData V4 demo service from https://blogs.sap.com/2017/12/05/new-sap-gateway-demo-system-available/ or with https://services.odata.org/TripPinRESTierService

AswinDC commented 1 year ago

@boghyon let me check try to consume std. V4 sample service. But it works perfectly if I change the binding as, binding="{/xWUPxWHSetting('BS01')}" But is it possible to change the key parameter BS01 after i do some action?? Kindly help me in a small snippet code since I am not sure which approach should I follow

Response if I use binding as -

  1. binding="{path: '/xWUPxWHSetting', parameters : {$filter : 'Warehouse eq \'BS01\''} }" image

  2. binding="{/xWUPxWHSetting('BS01')}" image

For the first one i am receiving it under value but for the second one is direct. Kindly let me know how should i change my bindings to use the first one & how to change the parameter's after some action

Thanks & Regards, Aswin.

boghyon commented 1 year ago

I just realized your binding definition was applied to binding while the path: '/xWUPxWHSetting' refers to an entity set. Please note that the binding attribute in XML is only for binding a single entity (element binding).


But is it possible to change the key parameter BS01 after i do some action?

This is bit broad to answer without knowing the context of the application. Please use one of the platforms mentioned in https://openui5.org/community/ for consulting questions in application development.

UweReeder commented 1 year ago

Hi @AswinDC,

If you want to change the form's binding later, you should not give it a binding initially. You can always set the binding context dynamically using setBindingContext, and you can always create a binding context via the model. So, initialize the binding in your controller via

oForm.setBindingContext(oModel.createBindingContext("/xWUPxWHSetting('BS01'))

and later create you can create another binding context (or use one that you got otherwise, e.g. from an action) and set it similarly.

Regards, Uwe

AswinDC commented 1 year ago

Hi @UweReeder

Thanks for the feedback!!! But how do I perform the oData call after setting the binding context?

UweReeder commented 1 year ago

What OData call? The GET request for the entity? It will be sent automatically as soon as the binding is resolved (meaning it has a valid OData binding path), which is the case after calling setBindingContext.

AswinDC commented 1 year ago

Yeah just now figured it out it does the GET automatically thanks for the response helped me a lot !! :-)

AswinDC commented 1 year ago

Hi @UweReeder

When i try to change something in the simpleform it tries to automatically update to Backend. How do I stop this? I want to make an update only when clicking on a button Getting this error as well, image

UweReeder commented 1 year ago

This question now is far beyond the original topic of this issue. And I'm afraid a GitHub issue is not meant as a consulting session for various topics regarding application development.

May I refer to @boghyon's comment again? Please use one of the platforms mentioned in https://openui5.org/community/ for consulting questions in application development.

But some hints: My original hint might have been too short. Your form probably needs a binding with empty path: binding="{}". And have a look at updateGroup in ODataModel.