avatar image
Former Member

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

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Dec 27, 2016 at 09:37 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 27, 2016 at 01:21 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 28, 2016 at 04:46 AM

    I got it fixed with the above suggestions.

    Thanks for the replies.

    Add comment
    10|10000 characters needed characters exceeded

Skip to Content