0

I am working on angular project I am using smart table. I have my .html as given

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

the .ts file is as follow

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);

  }
}

I want to get the edited data of the table but I am not getting it. The properties in ng-smart-table are as given

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

any help?

Faisal Amdani
  • 109
  • 14

1 Answers1

0

So the issue was you had the wrong keyword for edit confirmation, it's confirmSave and not confirmEdit

i copy the final code that i made work on my 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();
   }
 }
}
Flow
  • 550
  • 1
  • 4
  • 12
  • Its giving me previous data not updated data. also its not clicking on to the saveButton. – Faisal Amdani Feb 08 '18 at 13:08
  • sry it was `event.newData` and not `event.data`, i edited my answer – Flow Feb 08 '18 at 13:15
  • delete function is working edit is not working i want edited data. – Faisal Amdani Feb 08 '18 at 13:20
  • yep. if you want the documentation page i used it's here: https://github.com/akveo/ng2-smart-table/blob/master/src/app/pages/examples/various/advanced-example-confirm.component.ts – Flow Feb 08 '18 at 13:38
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/164756/discussion-between-faisal-amdani-and-flow). – Faisal Amdani Feb 08 '18 at 13:49