Can I use the 'nn rows copied' popup in my own code?

Can I use the 'nn rows copied' popup in my own code?

jladburyjladbury Posts: 52Questions: 15Answers: 0

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

  • kthorngrenkthorngren Posts: 22,480Questions: 26Answers: 5,167
    edited May 27

    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 action function. Hopefully it will give you ideas of how to show your message.

    Kevin

  • allanallan Posts: 65,752Questions: 1Answers: 10,937 Site admin
    Answer ✓

    buttons.info() is the public API to the code that triggers the popover. You can use that for whatever message / information you need.

    Allan

  • kthorngrenkthorngren Posts: 22,480Questions: 26Answers: 5,167

    Wow, after all these years I didn't run across that API :smile:

    Kevin

  • jladburyjladbury Posts: 52Questions: 15Answers: 0

    Kevin, I'm glad you said that! It was hiding in plain sight and I missed it.
    Allan, thanks yet again.

  • allanallan Posts: 65,752Questions: 1Answers: 10,937 Site admin

    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

Sign In or Register to comment.