SAPUI5 SmartTable pressItem事件被触发两次

时间:2018-12-11 15:53:25

标签: sapui5

我有一个问题,PhotoImage()事件在smarttable(sapui5)上被触发了两次。

智能表的类型为from tkinter import * root=Tk() imgstring = "/9j/4AAQSkZJRgABAQEASABIAAD/4QCMRXhpZgAASUAADADEBFAH/2Q==" img = PhotoImage(data=imgstring) panel = Label(root,image=img) panel.pack() root.mainloop()

pressItem

1 个答案:

答案 0 :(得分:0)

如果尚未onAfterRendering调用onInit,请重新考虑重命名函数 oTable.onAfterRendering

onAfterRendering在控制器生命周期中已经被调用,您可以尝试创建一个新函数,然后在onAfterRendering中调用它。

See this answer

onAfterRendering: function() {
    this.tableItems();
  },

  tableItems: function() {
    var tTable = this.byId("LineItemsSmartTable");
    var oTable = this.byId("LineItemsSmartTable").getTable();
    oTable.setMode(sap.m.ListMode.SingleSelectMaster);

    oTable.attachItemPress(function(oEvent) {
      alert("Pressed");
    });

    tTable.attachDataReceived(function() {
      var aItems = oTable.getItems();
      if (aItems.length === 0) return;
      $.each(aItems, function(oIndex, oItem) {
        oItem.setType("Active");
      });
    });

  }