CSV and Copy buttons not working (not SWF location related)

CSV and Copy buttons not working (not SWF location related)

LeighLeigh Posts: 22Questions: 2Answers: 0
edited November 2012 in TableTools
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]

Replies

  • LeighLeigh Posts: 22Questions: 2Answers: 0
    To add to this, I get no errors in the console.

    Anyone have any ideas as to what the problem could be?
  • robertbrowerrobertbrower Posts: 158Questions: 1Answers: 0
    Is the data table in a ui tab or dialog?
  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin
    I'd guess you are initialising the table hidden and therefore need to use http://datatables.net/extras/tabletools/api#fnResizeButtons when the table is made visible.

    Allan
  • LeighLeigh Posts: 22Questions: 2Answers: 0
    Thanks for getting back to me.

    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.
  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin
    Please give us a link to the page then, so we can see what is happening. At the moment we don't have enough information to be able to help.

    Allan
  • LeighLeigh Posts: 22Questions: 2Answers: 0
    Hi Allan. Am I able to send you the files?
  • LeighLeigh Posts: 22Questions: 2Answers: 0
    edited November 2012
    Allan - I've amended my original post to include the full source. (I've removed the dynamic generation, for simplicity)
  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin
    That look alike it should work to me. If you could link us to a page what isn't working that would be helpful.

    Allan
  • LeighLeigh Posts: 22Questions: 2Answers: 0
    It's not hosted anywhere - I run it under file://

    The flash has loaded - I've also substituted it for a animation flash file, and it plays fine.
  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin
    edited November 2012
    > I run it under file://

    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
  • LeighLeigh Posts: 22Questions: 2Answers: 0
    edited November 2012
    Thanks Allan - I did mention it in my original post:

    >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).
  • LeighLeigh Posts: 22Questions: 2Answers: 0
    Shame. I'll have to drop using this, as I needed to get this working by today. Thanks for your help though.
  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin
    > As the animation SWF plays, I assume Flash is working just fine under file://?

    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
  • LeighLeigh Posts: 22Questions: 2Answers: 0
    Thanks again Allan. I'll give it one more try, as it's a great tool and I'd really like to get it working.

    Cheers!
This discussion has been closed.