TableTools adding custom buttons more than 1

TableTools adding custom buttons more than 1

chrisdanachrisdana Posts: 0Questions: 0Answers: 0
edited August 2013 in TableTools
I refer to this link :
http://datatables.net/release-datatables/extras/TableTools/plug-in.html
and try to add 2 more custom buttons but the both button trigger same event.

Do anyone have face this issue?

The code in jquery document ready is:
[code]
"oTableTools": {
"sSwfPath": "../Scripts/TableTools/swf/copy_csv_xls_pdf.swf",
"aButtons": [
{
"sExtends": "delete_doc",
"sButtonText": "Delete",
"sDiv": "delete",
},
{
"sExtends": "send_doc",
"sButtonText": "Send",
"sDiv": "send",
},
{
"sExtends": "copy",
"mColumns": [5, 6, 7, 8, 9, 10, 11, 12, 14]
},
{
"sExtends": "csv",
"mColumns": [5, 6, 7, 8, 9, 10, 11, 12, 14]
},
]
},
[/code]

and event code for the button are
[code]
TableTools.BUTTONS.delete_doc = $.extend( true, TableTools.buttonBase, {
"sAction":"div",
"sTag":"default",
"sToolTip":"Delete Invoices",
"sNewLine": "
",
"sButtonText": "Delete",
//"sDiv": "",
"fnClick": function( nButton, oConfig ) {
Alert("Delete");
}
});

TableTools.BUTTONS.send_doc = $.extend( true, TableTools.buttonBase, {
"sAction":"div",
"sTag":"default",
"sToolTip":"Send Invoices",
"sNewLine": "
",
"sButtonText": "Send",
//"sDiv": "send",
"fnClick": function( nButton, oConfig ) {
Alert("Send");
}
});
[/code]


Thanks for your time!

Replies

  • sergio_de_la_lunasergio_de_la_luna Posts: 5Questions: 1Answers: 1
    I add the same issue and could solve it by typing:
    [code] $.extend( {}, TableTools.buttonBase, {[/code]
    instead of
    [code] $.extend( true, TableTools.buttonBase, {[/code]
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    [code]
    $.extend( true, {}, TableTools.buttonBase, {
    [/code]

    is best - deep copy into a new object.

    Allan
This discussion has been closed.