Closed titkalpesh closed 2 years ago
Hi @kalpeshtreesha,
So this isnt possible atm without some hacky code but i am open to PR's to add this functionality. Ive been trying to find a clean implementation for this for a while but its never really been good enough.
Honestly i usually just include a view button and then link to another page for update/ delete etc but i do see the use case.
@jamesdordoy Thanks for quick update. Appreciated..!!
hi @kalpeshtreesha ... I had the same problem.. I found a solution but not the best one... here is the trick... in your columns array, define your action button column like this, { label: 'Action Buttons', name: JSON.stringify({ buttons: [ { name: 'Edit', iconClass: "" }, { name: 'Delete', iconClass: "" }, ], }), orderable: false, classes: { btn: true, "btn-primary": true, "btn-sm": true, "ml-2": true, }, event: "click", component: ActionButtonsComponent, handler: this.actionHandler, },
in your ActionButtonComponent html,
In your click handler,
actionHandler(data, action) { if (action === 'Edit') this.editData(data); else if (action === 'Delete') this.deleteData(data); }
Note : This will stop sortable behavior of the column, I think the table uses the name property to sort column data
https://jamesdordoy.github.io/laravel-vue-datatable/examples/injecting-dynamic-components
As shown in this example there is one component. is it possible to inject multiple component in one column or can have multiple active like view, edit, delete button in last common in one component and all have different methods?