cancel
Showing results for 
Search instead for 
Did you mean: 

How to read oData property

former_member602416
Participant
0 Kudos

Hi,

i am creating an application where I need to read one of the property from oData service and then need to do some conversion and display converted data in UI5 page.

For example: odata service name is Service and property name is property1, i need to read property1 if it is '01' i need to display 'Gas' and if '02' need to display 'Elec' in UI5 page.

I do understand a function is required in controller to do the conversion and then need to send converted data to view. But how to pass the data back to view from controller function and how to read property from odata service.

Can some please help?

Accepted Solutions (0)

Answers (1)

Answers (1)

scott_stefanich
Active Participant
0 Kudos

Hello Swati,

I highly recommend the SAPUI5 Developer Guide's Application Best Practices.

Specifically, Step 6: Custom Utilities details using a Formatter to convert a property.

The examples include converting a string to uppercase, but you can apply your own conversion, for example, a JavaScript Switch statement to return 'Gas' for '01', 'Elect' for '02', and so forth.

For reading properties, a model is set in the Component which is then available throughout the app. In the best practices example, the Master view is bound to the Products Set, "{/Products}". A selected Product is bound to the Detail view and individual properties can be bound, e.g. "{DiscontinuedDate}". The property DiscontinuedDate is then formatted using the Formatter.js.

Hope this helps,

Scott