2

Is it possible to handle an onClick event on a Smart Table? I have annotated data coming from my backend. When clicking on an entry, I want to navigate to a new view displaying all data associated with the entry I clicked on.

How can I achieve this in SAPUI5? I can get the internal table with getTable in my JavaScript Controller, but how do I proceed?

Eldwin
  • 169
  • 2
  • 14
Regyn
  • 53
  • 1
  • 8

2 Answers2

1

On sap.m.Table you can add attachItemPress(oData?, fnFunction, oListener?) and fnFunction will be called to handle the item press.

Because you are trying to use a SmartTable, you need to take into account the TableType. This will really determine the means to handle the 'click'.

Check the tableType of your smartTable and then follow the api reference for that table. If the tableType is sap.ui.comp.smarttable.TableType.ResponsiveTable, then the above should work.

  • Sadly the function is not called. The table type is defined in the xml view as tableType="ResponsiveTable". Also, how can I get the corresponding odate in the specified function? – Regyn Jan 24 '17 at 14:27
  • I am using this: this.byId("flightstable").getTable().attachItemPress(this.handleRowPress); – Regyn Jan 24 '17 at 14:56
  • Since you are using a sap.m.Table in an xml view have you tried adding press="myControllerFunctionName" attribute to the ColumnListItem tag on the table? – RelativePeezyness Jan 24 '17 at 15:13
  • table.setMode(sap.m.ListMode.SingleSelectMaster); table.attachSelectionChange seems to work. Thanks for your help. Now I am trying to get the oModel binded to that specific table entry – Regyn Jan 24 '17 at 15:20
0

For me works attachSelectionChanged(oData?, fnFunction, oListener?) : sap.ui.model.SelectionModel. And after this I used that help https://stackoverflow.com/a/36913953/6039287 for get row item params. Works perfect:)

KiUB
  • 1
  • 1