2

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!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Kinjal
  • 91
  • 2
  • 9

2 Answers2

2

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

Sachin Shah
  • 4,503
  • 3
  • 23
  • 50
1

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]);
}
Yoarthur
  • 909
  • 9
  • 20
  • thanks for the reply but I have tried it. It's not working! @Yoarthur – Kinjal Dec 19 '18 at 14:16
  • import { VisitGymModule } from './smart-table-demo/smart-table.module' into the router app.module. And also fix the bugs you've and send me the link again. – Yoarthur Dec 20 '18 at 05:13
  • I have added module in app.module.ts still not working. And also I have added dependency for smart table then also it is not importing properly! @Yoarthur – Kinjal Dec 20 '18 at 05:39