cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Fiori/SAPUI5 reading view fields

Former Member
0 Kudos

Hi folks,

I am new to Fiori development and have did my research before asking this question here.

I have also completed the openSAP course on building a fiori App which was quite straight forward, but my question is based on manipulating the data on the front end and so not covered by the course.

I am looking for examples of manipulating the data on the screen based on the values returned by the back end system.  For example changing the colour fond of a PO which is above a certain value.  I am using the master/detail template and making using the webide with mock data.

I have been updating the Detail.controller.js, but I am not even able to update a field to a value like this

this._myfield = this.byId("text7");

but this could be because I haven't referenced the View, just tried to grab the field directly by ID.

If anyone knows of any sample snippets of code that shows front end field manipulation to change colour, value etc, I would be most greatful.

Note: these changes are not to go back to the back end, just view.

Thanks in Advance

Message was edited by: Michael Appleby

Accepted Solutions (0)

Answers (3)

Answers (3)

kedarT
Active Contributor
0 Kudos

Hi Caolan,

Hope this helps - http://jsbin.com/doboyi/3/edit?html,css,js,output

It is based on JSON Model but the same can be applied to oData Model also

Former Member
0 Kudos

Has anyone got any guidance on this, what I thought was a simple subject?

TIA

agentry_src
Active Contributor
0 Kudos

may have more information on this topic.  Take a look and let me know if I should move your Discussion there.

You may also wish to use Google Custom Search to better identify content of interest.

If it is a simple subject, it is likely already answered and you simply did not find the answer when using the SAP Search.  is also worth reading.

Regards, Mike (Moderator)

SAP Technology RIG

Former Member
0 Kudos

Michael I have searched a lot on SCN including the developer centre.

Can you move it to the SAPUI5 as you suggested?

Maybe change title from Simple Fiori example to SAP Fiori/SAPUI5 reading view fields.

Thanks

agentry_src
Active Contributor
0 Kudos

As requested, the title is changed.  Also Discussion successfully moved from SAP Fiori to SAPUI5 Developer Center.

Cheers, Mike (Moderator)

SAP Technology RIG

agentry_src
Active Contributor
0 Kudos

Discussion successfully moved from SAP for Mobile to SAP Fiori as the more appropriate community for this topic.

Regards, Mike (Moderator)

SAP Technology RIG

Former Member
0 Kudos

Thanks Michael ... sorry I put in the wrong group.

Continuing on with my problem...

As mentioned I am new to UI5/Fiori and currently can only read text elements on the details screen which I put there using

var oView = this.getView();

var var_string = oView.byId("text7").getText();

but trying to read something like (value) isn't working even if I use .getValue.

I know I am probably missing something missing, so can anyone help?

TIA

santhu_gowdaz
Active Contributor
0 Kudos

If it is Text the use getText() will gives the Text.

If it is Input then getValue() will return the value.

For changing the color you can use custom css. search in google "Custom css in UI5".

Former Member
0 Kudos

If its a text field on the screen definied as

<Text text="SampleText" maxLines="0" id="text7"/>

oView.byId("text7").getText();

works

but if this a value field

<Text id="text1" text="{Quantity}" maxLines="0">

  </Text>

Then

oView.byId("text1").getValue();

throws an exception

I am simply just trying to read the value of that field


Thanks

former_member182862
Active Contributor
0 Kudos

Hi Caolan

In both case, you use getText()

Thanks

-D