TableTools Copy to Clipboard

TableTools Copy to Clipboard

keroger2kkeroger2k Posts: 3Questions: 0Answers: 0
edited February 2013 in TableTools
I'm using table tools extra of the datatables jquery plugin. I'm wanting to be able to click on the copy to clip board button and have all the results of my datatable put into the buffer. Right now when I click on this button it is only displaying those in the datatable. Obviously I need to high jack this event somehow and call the server requesting all the the records, not those just currently being displayed in the table. I just am unsure on how to accomplish this task? I would like to do the same for CSV and XLS.

While you are at it, if you have a suggestion on how to better accomplish the 'aoColumnDefs' i'm doing that would be great. Seems awfully clunky to add a input of type checkbox and a href for a column. But perhaps that is just how it is designed.

Here are my options that I'm using:
[code]
var options = {
"sPaginationType": "full_numbers",
"sDom": "<'row-fluid'<'span6'T><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
"sPaginationType": "bootstrap",
"oTableTools": {
"sSwfPath": "/Content/DataTables-1.9.4/extras/TableTools/media/swf/copy_csv_xls.swf"
},
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": '/home/data',
"aoColumns": [
{ "mData": "Name" },
{ "mData": "Exception" },
{ "mData": "Imported" },
{ "mData": "Id" }
],
"aoColumnDefs": [
{
"aTargets": [1], fnRender: function (object, value) {
return (value) ? '' : ''
}
},
{
"aTargets": [3], "bSortable": false, fnRender: function (object, value) {
return "";
}
},
],
"oTableTools": {
"aButtons": ["copy", "csv", "xls"]
}
//"oTableTools": {
// "aButtons": [{
// "sExtends": "ajax",
// "sButtonText": "CSV Export",
// "fnClick": function (nButton, oConfig) {
// var oParams = this.s.dt.oApi._fnAjaxParameters(this.s.dt);
// console.log(nButton, oConfig, oParams, this);
// }
// }]
//}
};

$('table').dataTable(options);
[/code]

Replies

  • allanallan Posts: 63,494Questions: 1Answers: 10,470 Site admin
    > "bServerSide": true

    TableTools is client-side, but you've got server-side processing enabled. So an export on the client-side is already going to be incomplete (that's the whole point of server-side processing of course). So the question is, do you really need server-side processing?

    Allan
  • keroger2kkeroger2k Posts: 3Questions: 0Answers: 0
    I have 14k records. I tried by putting them all in the table on the initial load and it took probably 5-10 seconds to load. It has to be on demand and if the user wants all the data I'd like to have a button they can just click to say export all. Perhaps this isn't possible with TableTools and I should just create a button independent of DT.
  • allanallan Posts: 63,494Questions: 1Answers: 10,470 Site admin
    Possibly. The simple fact of the matter is that if you want a full copy to clipboard, you need all of the data on the client-side, so you'll need to load it at some point.

    5-10 second with an Ajax load and deferred rendering enabled?

    Allan
  • keroger2kkeroger2k Posts: 3Questions: 0Answers: 0
    I'm not familiar with Deferred Rendering? I looked at the documentation, but it was a bit unclear to me how it works. I see the initial load will just be there because you render it out via HTML. Will there just be one more load that runs via ajax to load all the records? This is the only way I can see the filtering/sorting/paging working correctly?
This discussion has been closed.