Buttons: Is there a size limit for copy?

Buttons: Is there a size limit for copy?

sscovilsscovil Posts: 2Questions: 1Answers: 0

I am using DataTable (v1.10.12) with the Buttons extension (v1.2.1) and noticed in Chrome (v50) that, with a reasonably-sized dataset (~600KB when exported to CSV), when I use the 'copyHtml5' button it says that the rows have been copied to the clipboard -- but they have not been. Whatever I had copied prior to using the copy button gets pasted.

Is there a size limit for copy? If so, is it dictated by the browser, a limitation of the Selection API, or something else?

Thanks in advance!

Answers

  • sscovilsscovil Posts: 2Questions: 1Answers: 0
    edited June 2016

    This change to buttons.html5.js enables the user to copy data that is too large by falling back to the CTRL+C method:

    try {
        var successful = document.execCommand( 'copy' );
        hiddenDiv.remove();
    
        if (successful) {
            dt.buttons.info(
                dt.i18n( 'buttons.copyTitle', 'Copy to clipboard' ),
                dt.i18n( 'buttons.copySuccess', {
                    1: "Copied one row to clipboard",
                    _: "Copied %d rows to clipboard"
                }, exportData.rows ),
                2000
            );
            return; // only return if successful, otherwise fall back to CTRL+C method
        }
    }
    catch (t) {}
    

    Submitted PR: https://github.com/DataTables/Buttons/pull/92

  • allanallan Posts: 63,799Questions: 1Answers: 10,514 Site admin

    Awesome - thanks! I'm pull the PR in on Tuesday. I'm travelling at the moment, and will be back then.

    Allan

This discussion has been closed.