Can I use the 'nn rows copied' popup in my own code?
Can I use the 'nn rows copied' popup in my own code?
in DataTables
The copy button puts up a message after copying to the clipboard. I have a specialised similar button in which I would like to display a similar popup. Is this possible?
Here is my current button definiton:
{
text: 'Clipboard (formatted)',
className: 'c9btnEditor',
attr: {
id: 'c9btnCopyFormatted'
},
action: async function (e, dt, node, config) {
let element = $('.dt-scroll')[0];
await BUtils.copyToClipboard(element);
**alert('Table copied to clipboard');**
$('.dt-button-collection').hide();
$('.dt-button-background').hide();
},
titleAttr: 'Copy formatted table to clipboard'
},
I want to replace the 'alert' with the DataTables popup.
This question has an accepted answers - jump to answer
Answers
The Buttons Copy code can be found in buttons.html5.js. The Copy code starts on line 918. Haven't tried using it so not sure you can just paste it into your
actionfunction. Hopefully it will give you ideas of how to show your message.Kevin
buttons.info()is the public API to the code that triggers the popover. You can use that for whatever message / information you need.Allan
Wow, after all these years I didn't run across that API
Kevin
Kevin, I'm glad you said that! It was hiding in plain sight and I missed it.
Allan, thanks yet again.
It should probably be a static function to be honest. I've hummed and hawed about putting it into DataTables core before as well, since it could be used in a number of other places (AutoFill, Responsive, etc) but never wanted to include what might be redundant code in the core. Maybe one day
Allan