Add copy to clipboard button to each row
Add copy to clipboard button to each row
csaba911
Posts: 17Questions: 4Answers: 0
in DataTables
Copy to clipboard works great but I would like to have them in each row instead of selecting a row and tap the copy button.
Managed to add a button to each row and style it with a class I wanted but now how to trigger the copy function and alert same notification as the one on the top of the page
This question has an accepted answers - jump to answer
Answers
Interesting question. See this example:
http://live.datatables.net/xezupobe/1/edit
It uses the exportOptions of the
copyHtml5
button to select the rows to export. Thebuttons.exportData()
docs document all the options available. It uses therow-selector
as a string (classname).The button click event adds the configured classname then uses
button().trigger()
to trigger the appropriate button. It then removes the classname.Optionally it uses
initComplete
to get thebutton().node()
in order to hide the button.Kevin
Perfect, Thanks
Grrr, now I would like to copy the fist cell data only, no header, footer or table name, just the first cell of the row where the button is being pressed.
well I'm butchered this together to make it work but I'm sure there is way to do it properly in data tables.
There are Buttons extension options to make these changes. The column selector example shows how to specify the columns to export. You can use any
column-selector
like just the column number. See this example for controlling thetitle
(table name) and this example for enabling the footer, which is disabled by default. You can use the same technique to disable the header withheader: false
.Or you can create your own custom function like above.
Kevin