CSV and Copy buttons not working (not SWF location related)
CSV and Copy buttons not working (not SWF location related)
Leigh
Posts: 22Questions: 2Answers: 0
I cannot get the CSV and Copy buttons to do anything. The SWF file is loading correctly and is definitely working, but clicking on the CSV and Copy buttons does nothing. I've even added an alert to click event in TableTools.js (below), but it's never reached!?
[code]
"fnClick": function( nButton, oConfig, flash ) {
alert("!");
this.fnSetText( flash, this.fnGetTableData(oConfig) );
}
[/code]
I should add that I'm running this from a file:// hosted html file (not a web server) ,and the table is dynamically generated (see below). I've tried with static data, but that made no difference.
Any ideas?
And here's the full source:
[code]
<!DOCTYPE HTML>
Export
$(function ()
{
$('table#export').dataTable({
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": false,
"bInfo": false,
"bAutoWidth": false,
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"sSwfPath": "assets/jquery-dataTables/extras/tableTools/media/swf/copy_csv_xls_pdf.swf",
"aButtons": [
{
"sExtends": "copy",
"sButtonText": "Copy to Clipboard"
},
{
"sExtends": "csv",
"sButtonText": "Export to Excel"
}
]
}
});
var oTableTools = TableTools.fnGetInstance('export');
oTableTools.fnResizeButtons();
});
NameJob TitleCompanyEmail Address
????
????
????
[/code]
[code]
"fnClick": function( nButton, oConfig, flash ) {
alert("!");
this.fnSetText( flash, this.fnGetTableData(oConfig) );
}
[/code]
I should add that I'm running this from a file:// hosted html file (not a web server) ,and the table is dynamically generated (see below). I've tried with static data, but that made no difference.
Any ideas?
And here's the full source:
[code]
<!DOCTYPE HTML>
Export
$(function ()
{
$('table#export').dataTable({
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": false,
"bInfo": false,
"bAutoWidth": false,
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"sSwfPath": "assets/jquery-dataTables/extras/tableTools/media/swf/copy_csv_xls_pdf.swf",
"aButtons": [
{
"sExtends": "copy",
"sButtonText": "Copy to Clipboard"
},
{
"sExtends": "csv",
"sButtonText": "Export to Excel"
}
]
}
});
var oTableTools = TableTools.fnGetInstance('export');
oTableTools.fnResizeButtons();
});
NameJob TitleCompanyEmail Address
????
????
????
[/code]
This discussion has been closed.
Replies
Anyone have any ideas as to what the problem could be?
Allan
The table is the only element on the page - I'm writing a simple export page. The table is visible, but it only contains a thead row initially.
I tried the fnResizeButtons call, but the buttons still aren't doing anything. They are visible and look fine, they just don't seem to fire any events.
Allan
Allan
The flash has loaded - I've also substituted it for a animation flash file, and it plays fine.
That's always been the case? Shame we didn't know that - I could have told you immediately what the problem was rather than this taking days. Unless you have a flash security exception setup it won't work under file:// for security reason, built into Flash (not something TableTools can control). See: http://datatables.net/forums/discussion/11459/do-we-need-webserver-for-tabletools-to-work/p1
>I should add that I'm running this from a file:// hosted html file
I'd already tried tweaking the Flash settings before I started this thread (as I'd seen it mentioned in another thread), but it still didn't work. I replaced the SWF file with a simple animation SWF and the animation plays in the top left of the page. As the animation SWF plays, I assume Flash is working just fine under file://?
The click events aren't firing in jQuery (see my alert code at the top of my original post).
No that is not the case. There needs to be a security exception for the file API access.
Just throwing it on a web-server should make it work.
Sorry I missed the file:// in the original post!
Allan
Cheers!