/scripts/ahub.form.attachments.js
0

How to get selected value from or controls written in XML view?

Dec 27, 2016 at 08:25 AM

148

avatar image
Former Member

Hi All,

I am trying to develop a Salesforce app using viz frame controls.

For "Monthly sales performance", I have to choose the year from the Combobox or select control and pick the selected value and pass it to the Odata dynamically.

Please tell me how to get selected value from the Combobox?

Here's my coding below:

View.xml:

http://www.w3.org/1999/xhtml">

<Label text="Choose Year" />

<content> <Select id="selectId" text="/items" change ="onSelect" >

<items> <core:Item text="2016"/> <core:Item text="2014"/> <core:Item text="2015"/> <core:Item text="2014"/> <core:Item text="2013"/> <core:Item text="2012"/> <core:Item text="2011"/> <core:Item text="2001"/> <core:Item text="2000"/> <core:Item text="1999"/> </items> </Select> </content> <Button id = "btn" text="Click" press="onClick"/>

<content> <viz:VizFrame xmlns="sap.viz" id="idpie" width="100%" vizType="pie" > </viz:VizFrame> </content> </Page> </core:View>

view.controller.js:

onSelect:function(oEvent)

var aItems =oEvent.getSource().getBindingContext("text").getValue();

alert(aItems);

var selectedVal1 = this.getView().byId('selectId').getLiveValue();

alert(selectedVal1);

Please suggest.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
avatar image
Former Member Dec 27, 2016 at 09:37 AM
0

Hello Lalitha ,

Please try this code :

event.oSource.getSelectedItem().getTitle()

I got the required output as this is for the list, and i got the title of the selected item.

Now u want for the Combobox, so u can try with getText()


Thanks,

DEEPAK.

Share
10 |10000 characters needed characters left characters exceeded
Jun Wu Dec 27, 2016 at 01:21 PM
0

https://sapui5.hana.ondemand.com/#docs/guide/e5310932a71f42daa41f3a6143efca9c.html

use binding, the selected value will be in model, you don't have to go to ui control to get the value.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Dec 28, 2016 at 04:46 AM
0

I got it fixed with the above suggestions.

Thanks for the replies.

Share
10 |10000 characters needed characters left characters exceeded
Skip to Content