I use datatables and it's great. I would like use bSelectedOnly: true to save files (like by default) but i would like it saves all data if no rows are selected.
What you could do is customise the fnClick function for that button ( http://datatables.net/extras/tabletools/button_options#fnClick ) and modify the bSelectedOnly property of the object just before calling fnGetTableData, based on the number of rows selected (which you can get from the API TableTools presents).
The '1 row copied' is probably a different issue since you aren't actually sending any data to Flash - so likely it has copied only a new line character to the clipboard - hence the 1 line alert.
Rather than overriding fnClick, I'd suggest just using bSelectedOnly like in this code example: http://datatables.net/extras/tabletools/button_options#bSelectedOnly
The documentation for bSelectedOnly says "If no rows are selected, then all data is used." - which is exactly what you want (so my original suggestion was a little over the top - sorry).
Replies
Allan
I tried this and it didn't work.
{
"sExtends": "copy",
"fnClick": function ( nButton, oConfig, oFlash ) {
oConfig['bSelectedOnly'] = false;
}
},
which should always set the bSelectedOnly to false, but when I click on the button it will say "1 row copied"
Please help!
Rather than overriding fnClick, I'd suggest just using bSelectedOnly like in this code example: http://datatables.net/extras/tabletools/button_options#bSelectedOnly
The documentation for bSelectedOnly says "If no rows are selected, then all data is used." - which is exactly what you want (so my original suggestion was a little over the top - sorry).
Allan
That was my first option but it didn't work. It just says copied 0 rows to clipboard.
[code]
"oTableTools": {
"sSwfPath": "/media/swf/dataTables.copy_cvs_xls_pdf.swf",
"sRowSelect": "multi",
"aButtons": [
{
"sExtends": "select_all",
"sButtonText": "Select All"
},
{
"sExtends": "select_none",
"sButtonText": "Select None"
},
{
"sExtends": "copy",
"bSelectedOnly": true
},
{
"sExtends": "collection",
"sButtonText": "Export",
"aButtons": [ {
"sExtends": "csv",
"bSelectedOnly": true
},
{
"sExtends": "xls",
"bSelectedOnly": true
},
{
"sExtends": "pdf",
"sPdfOrientation": "landscape",
"bSelectedOnly": true
}]
},
{
"sExtends": "print"
}
]
},
[/code]
When I take away the "bSelectedOnly": true, it copies corectly.
Thanks,
Allan
Unfortunately I can't provide a link sorry. :-S
Thanks