Search code examples
javascriptxmlsapui5

itemPress on a Table that was added from controller is not a function


I am adding a sap.m.Table from my controller to the view. I set the itemPress function just like in the view as itemPress: "onListItemPress" (in the view it would be itemPress="onListItemPress"). However when I press an item in the table and the event is fired, it doesn't 'find' the function, giving me the following TypeError: I.fFunction.call is not a function:

Error log from Console
My code:

var oTable2 = new sap.m.Table({
    id: "oTable2",
    mode: "SingleSelectMaster",
    keyboardMode: "Navigation",
    itemPress: "onListItemPress", // reeeee
    headerText: this.getTableHeaderText(),
    columns: this.getTableColumns()
});
var oTableContainer = this.getView().byId("idTableContainer");
oTableContainer.addItem(oTable2);

How do I reference the function in the controller when setting the control from the controller itself?


Solution

  • Try this. Hope it helps.

    itemPress: this.onListItemPress,