0

我正在使用智能表进行角度项目。我有给定的 .html

 <ng2-smart-table [settings]="settings" [source]="source"  (editConfirm)="onSaveConfirm($event)"
(deleteConfirm)="onDeleteConfirm($event)" >
    </ng2-smart-table>

.ts 文件如下

export class CoursesComponent {
settings = {
hideSubHeader: false,
mode: 'inline',

           edit: {
      editButtonContent: '<i class="nb-edit"></i>',
      saveButtonContent: '<i class="nb-checkmark"></i>',
      cancelButtonContent: '<i class="nb-close"></i>',
      //confirmEdit: true,
          },
    delete: {
      deleteButtonContent: '<i class="nb-trash"></i>',
      confirmDelete: true,
    },};

onDeleteConfirm(event): void {
console.log(event.data);
    if (window.confirm('Are you sure you want to delete?')) {
      event.confirm.resolve();
    } else {
      event.confirm.reject();
    }
  }
  onSaveConfirm(event): void {
console.log(event.data);

  }
}

我想获取表格的编辑数据,但没有得到。ng-smart-table 中的属性如给定

edit: {
                inputClass: '',
                editButtonContent: 'Edit',
                saveButtonContent: 'Update',
                cancelButtonContent: 'Cancel',
                confirmSave: false,
            },
            delete: {
                deleteButtonContent: 'Delete',
                confirmDelete: false,
            },

有什么帮助吗?

4

1 回答 1

0

所以问题是你有错误的编辑确认关键字,它是confirmSave而不是confirmEdit

我复制了我在我的 copuiter 上工作的最终代码:

export class CoursesComponent {
settings = {
  hideSubHeader: false,
  mode: 'inline',
  edit: {
     editButtonContent: '<i class="nb-edit"></i>',
     saveButtonContent: '<i class="nb-checkmark"></i>',
     cancelButtonContent: '<i class="nb-close"></i>',
     confirmSave: true,
   },
  delete: {
     deleteButtonContent: '<i class="nb-trash"></i>',
     confirmDelete: true,
  }
};

onSaveConfirm(event): void {
console.log(event.data);
   if (window.confirm('Are you sure you want to delete?')) {
      event.confirm.resolve();
      console.log(event.newData);
   } else {
     event.confirm.reject();
   }
 }
}
于 2018-02-08T12:59:33.797 回答