Skip to Content

How to get selected values from combobox in xml views from sapui5

Hey,

i am using MultiComboBox of xml views. How can i get the selected items without the oEvent ?

This example works fine:

abc: function(oEvent) {

oEvent.getParameters("selected")
oEvent.getParameters("changedItem")

}

But i need to get the Parameters byId. Working with oEvent is for my application not possible. I try it with getSelectedItems.. getItems... getItemByKey...

this.byId("myComboBox").getSelectedItems();

The problem with getSelectedItem is, if i try this:

https://i.gyazo.com/c10e33ba58555f6ff272622fa5d406a1.mp4

.getSelectedItems() are triggered and the Result are 0. If i pick a second item, my change handler get fired and .getselecteditems() give me back one item, my first pick! (postbox1).


But i need like oEvent.getParameters(....) all selected items.

Thanks for your help guys !

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • Best Answer
    Oct 08, 2018 at 05:09 PM

    You are using the event "change" for your MultiComboBox, if you use the event "selectionChange" your onSearch function should function correctly.

    More on this here: https://sapui5.hana.ondemand.com/#/api/sap.m.MultiComboBox/events

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 05, 2018 at 05:00 PM

    very hard to follow you for this part

    .getSelectedItems() are triggered and the Result are 0. If i pick a second item, my change handler get fired and .getselecteditems() give me back one item, my first pick! (postbox1).

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 05, 2018 at 11:04 PM

    When do you run your method? In the selectionFinish event, the selectionChange event, or some other way?

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 08, 2018 at 12:02 PM
    <MultiComboBox id="mb" change="onSearch">
    <items>
    	<core:Item key="1" text="One"/>
    	<core:Item key="2" text="Two"/>
    	<core:Item key="3" text="Three"/>
    </items>
    </MultiComboBox>
    
    onSearch: function (oEvent) {
    this.byId("mb").getSelectedItems();
    }


    If i select the first item, onSearch is triggered ! But getSelectedItems give me back 0.

    Todo: https://i.gyazo.com/c10e33ba58555f6ff272622fa5d406a1.mp4
    Result: https://i.gyazo.com/fb234e8a0bee5c9faa85575b9670de2f.png

    If i select a second item, onSearch is triggered and getSelecdItems give me back a array with my FIRST pick ! My second is ignored.

    Todo: https://i.gyazo.com/0f4109033cd579ad498d8ed87aa1e6b4.mp4
    Result: https://i.gyazo.com/1160715a1ce12ac331672e520ca287a3.png


    I cant work with oEvent, because onSearch are triggered by few different boxes.

    How i get the selected propertys ?

    Add comment
    10|10000 characters needed characters exceeded