Skip to Content
0

get selection of List Items

Dec 01, 2016 at 09:16 AM

49

avatar image

Hey,

i create a list with static content and want to get the selected item, but never the event handler was called. I hope you can tell what i do wrong.

The code of the list:

<List headerText="Individualisierung" id="colorSelection" selectionChange="onselectionChange">
  <InputListItem label="Giftgrün" id="x1">
	<RadioButton groupName="GroupInputListItem" class="colorLime"/>
  </InputListItem>
  <InputListItem label="Waldgrün" id="x2">
	<RadioButton groupName="GroupInputListItem" class="colorGreen"/>
  </InputListItem>
  <InputListItem label="Dunkelblau" id="x3">
	<RadioButton groupName="GroupInputListItem" class="colorBlue"/>
  </InputListItem>
  <InputListItem label="Türkis" id="x4">
	<RadioButton groupName="GroupInputListItem" class="colorAqua"/>
  </InputListItem>
  <InputListItem label="Orange" id="x5">
	<RadioButton groupName="GroupInputListItem" class="colorOrange"/>
  </InputListItem>
 </List>

The code of the method:

onSelectionChange : function() {
   console.log(this.getView().byId("colorSelection").getSelectedItem());
}

Thanks in advance!

Tim

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

1 Answer

Best Answer
Manne Prasad Dec 05, 2016 at 09:23 AM
0

Hello Tim,

For selectionChange Event set mode to "singleSelectMaster" in the list tag.

<List headerText="Individualisierung"  id="colorSelection" selectionChange="onselectionChange" mode="SingleSelectMaster">

now the event selectionChange gets triggered. Inside the event handler you can get the selected item by Event parameters.

onselectionChange: function(oEvent){ console.log(oEvent.getParameters("selectedItem")); }
Share
10 |10000 characters needed characters left characters exceeded