I created a simple plug-in for tabletools. How about this?

I created a simple plug-in for tabletools. How about this?

ts_3156ts_3156 Posts: 5Questions: 2Answers: 0

I created a simple plug-in for tabletools.
This plain_copy button removes currency signs when you copy text to clipboard.

I would be glad if you put it up on this page.
http://www.datatables.net/extensions/tabletools/plug-ins

I want to know what you think. (^^)

TableTools.BUTTONS.plain_copy =
  $.extend( {}, TableTools.buttonBase, {
    "sAction": "flash_copy",
    "sButtonClass": "DTTT_button_copy",
    "sButtonText": "Copy",
    "fnClick": function( nButton, oConfig, flash ) {
      var text = this.fnGetTableData(oConfig);
      // Change this list to the characters you want to remove
      this.fnSetText( flash, text.replace(/[$£€c,%]/g, "") );
    },
    "fnComplete": function(nButton, oConfig, flash, text) {
      var lines = text.split('\n').length;
        if (oConfig.bHeader) lines--;
        if (this.s.dt.nTFoot !== null && oConfig.bFooter) lines--;
      var plural = (lines==1) ? "" : "s";
      this.fnInfo( '<h6>Table copied</h6>'+
        '<p>Copied '+lines+' row'+plural+' to the clipboard.</p>',
        1500
      );
    }
  } )

I created a "plain_copy" button based on a "copy" button.
https://github.com/DataTables/TableTools/blob/bafa54d387a518abc46b297c6d7d9fda9dafdf6d/src/TableTools.js#L2425-L2442

tabletools / plug-ins
http://www.datatables.net/extensions/tabletools/plug-ins

Replies

  • allanallan Posts: 63,389Questions: 1Answers: 10,449 Site admin

    Very nice - thanks for sharing with us! I'm sure others will find it useful :-).

    I need to update how plug-ins work on the TableTools site so they can be properly version controlled. I'll include your plug-in when I do that.

    Regards,
    Allan

  • ts_3156ts_3156 Posts: 5Questions: 2Answers: 0

    Thank you for the reply.

    Please let me know if there is anything I can do. (^^)

This discussion has been closed.