How to use a link in TableTools instead of flash buttons

I am trying to find a way to change buttons in TableTools. I would like to use my own custom links instead of flash buttons. Is there a way I can do this? Any good resource that teaches me how to make this modification and is still able to use functionality such as a collection of buttons, etc.

+6
source share
2 answers

According to the creator , the only way to get TableTools export functionality is to use the Flash buttons.

The other threads you found should say no at the moment, this is not an option that TableTools provides. The Flash option is used to provide the ability to cross-browser / platform to save files completely on the client side - this option is simply not available in older browsers (IE6, IE7, etc.), where there is no data support: // protocol and local file system interaction parameters.

Of course, it would be possible to add this ability to TableTools, but I'm afraid I have not had the opportunity to do this yet. This is on a roadmap.

Allan

If you are interested in creating an export file server, you can consider the download plugin (GET) for TableTools.

+4
source

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] }); /**/ }); 
0
source

Source: https://habr.com/ru/post/915417/


All Articles