cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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:

<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" controllerName="sales_force.piescreen" xmlns:viz="sap.viz.ui5.controls" xmlns:html="http://www.w3.org/1999/xhtml"> <Page title="SALES ORDER OPEN" showNavButton="true" navButtonPress="onBac">

<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.

Accepted Solutions (1)

Accepted Solutions (1)

former_member203031
Contributor
0 Kudos

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.

Answers (2)

Answers (2)

Former Member
0 Kudos

I got it fixed with the above suggestions.

Thanks for the replies.

junwu
Active Contributor
0 Kudos

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.