cancel
Showing results for 
Search instead for 
Did you mean: 

[ComboBox] getSelectedKey()

Former Member
0 Kudos

Hi,

I tried to read out the currently selected Key from a simple ComboBox (NOT MultiComboBox!). I refer to this Example: SAPUI5 Explored and this how to get selected values from multi combobox ... | SCN

My Code:

XML

=============

<ComboBox items="{modelCombobox>/}" selectedItem="comboboxSelectedItem" selectedKey="comboboxKey" selectedItemId="comboboxSelectedItemId"

                        id="comboboxID" placeholder="Date" textAlign="Initial" textDirection="Inherit" maxWidth="100%"

                        selectionChange="onSelectionChangeCombobox">

                        <items>

                            <core:Item key="{modelCombobox>Listitem}" text="{modelCombobox>date}"/>

                        </items>

                    </ComboBox>

CONTROLLER

===============

[...]

onSelectionChangeCombobox: function(oEvent) {

            console.log(this.getView().getModel("modelCombobox").getSelectedKey());   // not a function

            console.log(this.getSelectedKey());      // not a function

            console.log(oEvent.getSelectedKey());   // not a function

            console.log(this.getModel().getProperty('/selected'));   // undefined

            console.log(this.getModel().getParameter('changedItem'));   // not a function

}

[...]

Every try failed, are there any other thoughts on this? Thanks in advance!

Accepted Solutions (1)

Accepted Solutions (1)

saivellanki
Active Contributor

Hi Soren,

It should be:


this.getView().byId("comboboxID").getSelectedKey();

(or)

oEvent.getSource().getSelectedKey();

Regards,

Sai Vellanki.

Former Member
0 Kudos

thank you! Was there any chance to read this on a documentation? I've never seen this code in any examples or docs yet.

Answers (0)