3

I have been working with the DataTables library in VisualForce and have everything working except for the export features. I followed the sample initialization on the DataTables website, but am getting an error that ZeroClipboard.js is undefined in the TableTools.js file. However, I have checked and re-checked multiple times and the zeroclipboard.js is listed as a resource in the Chrome.

The only thing I am doing differently, and was not able to determine in adapting the function to VisualForce was how to properly call the swf file. Currently I am hosting the file on a local server and referencing it explicitly in the function. Could this be my issue? The error above does not seem to be related, but it is the only thing left I think after extensive troubleshooting.

Does anyone know how I can make the swf file a static resource in Salesforce and call it that way from the function so the file is on the same server as everything else?

Below is my current function setting up DataTables (Question in reference to the swfPath: call, how do I do this with a static resource?)

      var oTableTools = new TableTools( oTable, {
        "sSwfPath" : "www.MyWebsite.com/resources/copy_csv_xls_pdf.swf",
        "buttons": [
                    "copy",
                    "csv",
                    "xls",
                    "pdf",
                    { "type": "print", "buttonText": "Print me!" }
                   ]
      });
            $('#demo').before( oTableTools.dom.container );
3
  • If you change the path to something else do you get a different error? What if you add http://?
    – Mike Chale
    May 2, 2013 at 15:10
  • Thanks Mike. I had the http://, and for referencing something else, I have tried referencing another site, but get the same exact results in both cases. I am thinking that none of that is working since what I am doing falls under Flash's cross domain protection policy.
    – bcorpnick
    May 2, 2013 at 15:21
  • That is why I am thinking it might be good to try and get the swf in Salesforce as a static resource, just not sure what the syntax for calling it would look like.
    – bcorpnick
    May 2, 2013 at 15:22

2 Answers 2

1

I'd expect your reference to the static resource to look something like:

"sSwfPath" : "{!URLFOR($Resource.ZipFileName,'SubfolderPath/copy_csv_xls_pdf.swf')}"

If not, I'd expect it to look very similar. Try it and see if it works.

I'm suggesting this because a static resource reference to an image file would look like:

img src="{!URLFOR($Resource.ZipFileName,'SubFolderPath/ImageName.xxx')}"

All you'd really be doing is replacing the http://www.mywebsite.com/path link in your sSwfPath with the Salesforce URL pointer to retrieve it from where it's being stored internal to Salesforce, plus any path saved within the zip file.

1

You can do this by uploading swf file(you can find this in the media/swf/copy_csv_xls_pdf ) as a static resource in salesforce and then accssesing it

For example

  oTable = $('#example').dataTable(
        {
            "iDisplayLength": 20,
            "sDom": '<C><"H"T><"clear"><"H"l>t<"F"ip>',
            "oTableTools": {
            "sSwfPath": "{!$Resource.SWF_File}"
            },
            "oColVis": 
            {
                "activate": "mouseover"
            },
            "bAutoWidth": false,
            "bJQueryUI": true, 
            "sPaginationType": "full_numbers",
            "aaSorting": [[ 2, "asc" ]] ,
            "bLengthChange": false, 
            "bFilter": true

The static resource SWF_File consists copy_csv_xls_pdf.swf

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .