sapui5

Smart Table, onclick event


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?


Solution

  • 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.