Kinjal
Kinjal

Reputation: 91

How to update data into another page using smart table in Angular 6

I am using ng2-smart-table in my angular project. Smart table is providing built-in add, edit and delete data but I don't want to use it. I want to edit data on another page, like we do for every CRUD operation. I have searched it but I did not find any solution. Does anyone know how I can do this? Thanks in advance!

Upvotes: 2

Views: 1398

Answers (2)

Sachin Shah
Sachin Shah

Reputation: 4533

I suggest you to make your custom icon with edit icon and put in action. For that block/deactive default edit button.

With that you will get your click event in (custom)="customeEdit($event)".

By this way you can use your custom component in ng2-smart-table.

Add custom icon

Upvotes: 2

Yoarthur
Yoarthur

Reputation: 917

You can redirect user by binding a method to (edit) event. like this.

.html

<ng2-smart-table  class="table"
                          [settings]="settings" 
                          [source]="data" 
                          (deleteConfirm)="onDeleteConfirm($event)"
                          (rowSelect)="onRowSelect($event)" 
                          (userRowSelect)="onUserRowSelect($event)"
                          (rowHover)="onRowHover($event)"
                          (create)="onCreateNewProcessor($event)"
                          (edit)="onEditData($event)"
                          (custom)="onCustom($event)"></ng2-smart-table> 

.ts

onEditData(event) {
    this.router.navigate(["/route/i/want/to", event.data.id]);
}

Upvotes: 1

Related Questions