Reputation: 4958
I have sapui5 table with selection mode Multi Select. I can get selected row data on a Button click event which is in the page.
And also I need to click on a row and get the data of the clicked row.
For this I've used ItemPress
event.
But I'm unable to get the clicked row data inside the ItemPress
Event
This is how I attach the evet
oView.byId("table1").getTable().attachItemPress(this.handleItemPress, this);
The Table
<Table id="table1" growing="true" growingThreshold="10" mode="MultiSelect">
<columns>
<Column id="TICKET_ID" hAlign="Begin" vAlign="Top" styleClass="iconCol">
<customData>
<core:CustomData key="p13nData" value='\{"columnKey": "TICKET_ID", "columnIndex":"0", "leadingProperty": "TICKET_ID"}'/>
</customData>
<Text text="{@i18n>Ticket}"/>
</Column>
<Column id="NUMBER" hAlign="Begin">
<customData>
<core:CustomData key="p13nData" value='\{"columnKey": "NUMBER", "maxLength": "40","columnIndex":"1", "leadingProperty": "NUMBER"}'/>
</customData>
<Text text="{@i18n>NUMBER}"/>
</Column>
</columns>
<items>
<ColumnListItem type="Active">
<cells>
<Text text="{TICKET_ID}"/>
<Text text="{NUMBER}"/>
</cells>
</ColumnListItem>
</Table>
Item Press Event
handleItemPress: function(oEvent) {
var rowobject = oEvent.getSource().getSelectedItem().getBindingContext().getObject();
},
This gives an error
Upvotes: 3
Views: 12297
Reputation: 4958
I think I found a way to access data
oEvent.getParameter("listItem").getBindingContext().getObject();
Upvotes: 2
Reputation: 241
If it is a multiple select enabling table, then you should have an OK button. User will select items and press OK. And you can collect selected item with something similar to this:
onOKPressed: function(oControlEvent) {
this.aTokens = oControlEvent.getParameter("tokens");
this.theTokenInput.setTokens(this.aTokens);
...
},
Upvotes: -1