TableTools Copy to Clipboard
TableTools Copy to Clipboard
keroger2k
Posts: 3Questions: 0Answers: 0
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]
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]
This discussion has been closed.
Replies
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
5-10 second with an Ajax load and deferred rendering enabled?
Allan