Yes, you can override existing buttons, such as PDF / CSV, etc., or create new custom buttons that have links to a URL to receive or publish data. Here I show 2 methods with get methods:
Learn more about Get and Post methods:
Visit: Datatable tabletools GET / POST boot method overrides
The generated pdf code is used because the pdf output from tableools in the table, which have rows grouped by some column data, overlaps.
1st to override the PDF function and
2nd to create a custom button.
1. Override the PDF function to extract the pdf of the server.
/*Get Method table Tools - PDF - Overriding*/ TableTools.BUTTONS.pdf = { "sAction": "text", "sTag": "default", "sFieldBoundary": "", "sFieldSeperator": "\t", "sNewLine": "<br>", "sToolTip": "", "sButtonClass": "DTTT_button_text", "sButtonClassHover": "DTTT_button_text_hover", //"sButtonText": "PDF", "mColumns": "all", "bHeader": true, "bFooter": true, "sDiv": "", "fnMouseover": null, "fnMouseout": null, "fnClick": function (nButton, oConfig) { var oParams = this.s.dt.oApi._fnAjaxParameters(this.s.dt); var iframe = document.createElement('iframe'); iframe.style.height = "0px"; iframe.style.width = "0px"; //iframe.src = oConfig.sUrl + "?" + $.param(oParams); iframe.src = oConfig.sUrl;//This is the URl you give in datatable Tabletools pdf override below document.body.appendChild(iframe); }, "fnSelect": null, "fnComplete": null, "fnInit": null }; /**/ /*Datatable initialisation*/ $(document).ready(function () { oTable = $('#alternatecolor').dataTable({ "bJQueryUI": true, "aLengthMenu": [ [10, 25, 50, 100, -1], [10, 25, 50, 100, "All"] ], "sPaginationType": "full_numbers", "aoColumns": [ null, null, null, null, null], "bLengthChange": false, "bPaginate": false, "sDom": '<"H"Tfr>t<"F"ip>', //"sDom": 'T<"clear">lfrtip', "oTableTools": { "aButtons": [ "csv", "xls", { /*PDF Override*/ "sExtends": "pdf", "sButtonText": "PDF", //Custom url to fetch pdf report "sUrl": " report/PDFReportUsers/us/1" } ] } }) /*Row grouping - optional*/ .rowGrouping({ bExpandableGrouping: true, bExpandSingleGroup: false, iExpandGroupOffset: -1 //asExpandedGroups: [name] }); /**/ }); });
2. Custom button to extract the pdf-code of the server.
/*Get Method table Tools - Download custom button*/ TableTools.BUTTONS.download= { "sAction": "text", "sTag": "default", "sFieldBoundary": "", "sFieldSeperator": "\t", "sNewLine": "<br>", "sToolTip": "", "sButtonClass": "DTTT_button_text", "sButtonClassHover": "DTTT_button_text_hover", //"sButtonText": "PDF", "mColumns": "all", "bHeader": true, "bFooter": true, "sDiv": "", "fnMouseover": null, "fnMouseout": null, "fnClick": function (nButton, oConfig) { var oParams = this.s.dt.oApi._fnAjaxParameters(this.s.dt); var iframe = document.createElement('iframe'); iframe.style.height = "0px"; iframe.style.width = "0px"; //iframe.src = oConfig.sUrl + "?" + $.param(oParams); iframe.src = oConfig.sUrl; document.body.appendChild(iframe); }, "fnSelect": null, "fnComplete": null, "fnInit": null }; /**/ $(document).ready(function () { oTable = $('#alternatecolor').dataTable({ "bJQueryUI": true, "aLengthMenu": [ [10, 25, 50, 100, -1], [10, 25, 50, 100, "All"] ], "sPaginationType": "full_numbers", "aoColumns": [ null, null, null, null, null], "bLengthChange": false, "bPaginate": false, "sDom": '<"H"Tfr>t<"F"ip>', //"sDom": 'T<"clear">lfrtip', "oTableTools": { "aButtons": [ "csv", "xls" , { "sExtends": "download", "sButtonText": "Download PDF", "sUrl": "admin/user/4/downloadfile" } ] } }) /*Row grouping - optional */ .rowGrouping({ bExpandableGrouping: true, bExpandSingleGroup: false, iExpandGroupOffset: -1 //asExpandedGroups: [name] }); /**/ });