Skip to Content

How to read oData property

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?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Mar 05, 2015 at 01:49 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.