无法在 angular 中的 ng2-smart-table 中获取删除事件 6

Not able to get delete event in ng2-smart-table in angular 6

我正在使用 ng2-smart-table 在 angular 6 应用程序中显示数据。现在我无法获得删除事件。我已经设置了这样的设置对象。

columns: {
  ... // Columns... 
},
edit: {
  confirmSave: true,
  editButtonContent: '...',
  saveButtonContent: '...',
  cancelButtonContent: '...'
},  
delete: {
   confirmDelete : true,
   deleteButtonContent: '...',
   saveButtonContent: '...',
   cancelButtonContent: '...'
},

在 HTML 文件中我设置了这个。

<ng2-smart-table [settings]="Settings" [source]="DataSource" (createConfirm)="onCreate($event)" (confirmDelete)="onRoleDelete($event)"></ng2-smart-table>

在 .ts 文件中

onRoleDelete(event) {
   alert("Delete works");
}

我已经检查过它是 git 并且还参考了其他示例。我也可以获取编辑事件,但不能只获取删除事件。

删除图标也在HTML文件中查看。

尝试 deleteConfirm 而不是 confirmDelete

Please refer Demo for better understanding

DEMO

移除mode: 'external',

<ng2-smart-table [settings]="settings" [source]="DataSource" (createConfirm)="onCreate($event)" (deleteConfirm)="onRoleDelete($event)"></ng2-smart-table>

配置:

  settings = {
    delete: {
      confirmDelete: true,
    },
    add: {
      confirmCreate: true,
    },
    edit: {
      confirmSave: true,
    },
    columns: {
      id: {
        title: 'ID',
      },
      name: {
        title: 'Full Name',
      },
      username: {
        title: 'User Name',
      },
      email: {
        title: 'Email',
      },
    },
  };

  data = [
    {
      id: 1,
      name: "Leanne Graham",
      username: "Bret",
      email: "Sincere@april.biz"
    },
    {
      id: 2,
      name: "Ervin Howell",
      username: "Antonette",
      email: "Shanna@melissa.tv"
    },

    // ... list of items

    {
      id: 11,
      name: "Nicholas DuBuque",
      username: "Nicholas.Stanton",
      email: "Rey.Padberg@rosamond.biz"
    }
  ];

  onDeleteConfirm(event) {
    console.log("Delete Event In Console")
    console.log(event);
    if (window.confirm('Are you sure you want to delete?')) {
      event.confirm.resolve();
    } else {
      event.confirm.reject();
    }
  }

  onCreateConfirm(event) {
    console.log("Create Event In Console")
    console.log(event);

  }

  onSaveConfirm(event) {
    console.log("Edit Event In Console")
    console.log(event);
  }

参考--->https://github.com/akveo/ng2-smart-table/blob/master/src/app/pages/examples/various/advanced-example-confirm.component.ts