Open Mashiane opened 4 years ago
also, there's no way to get an event callback whenever a cell is tapped/clicked? (Considering checkbox is hidden)
Is there a possibility to add buttons or actions on each row? I also need to do it.
+1 I also need similar functionality.
+1 I also need similar functionality
you can do something like this:
EXAMPLE:
let button_formatter = (value) => `<div class="print-item" doc-name-value="${value}">Print</div>`
the doc-name-value
attribute can be anything meaningful to you that you want to use in the print function later on
the (value)
bit can be changed to pass other information like this (value, columns, column, row_data)
The columns
parameter will get you all the columns of the row with detailed info such as column settings and html content
The column
parameter will get you the settings of this column
The row_data
parameter will get you the initial/original row data that you passed when initializing the datatable or using datatable.refresh()
please note:
_**1. you can name the parameters whatever
after that, you need to create a column for that button and set the format:
parameter value to the button_formatter
variable
const columns = [ ....
// print_btn
,{
name: ' ',
id: 'name_to_print',
editable: false,
resizable: false,
dropdown: false,
format: button_formatter
},
....
]
after that you can attach an event to the button with jQuery using the button class which is in this case is: print-item
Hi there
How can I add actions for each row, for example have 2 icons / buttons for Edit/Delete with events linked to them so that when I click on one, it actions the appropriate event called?
Thanks