DataTables TableTools plugin - How to configure sSwfPath path in Codeigniter?

NealCaffrey picture NealCaffrey · Apr 6, 2013 · Viewed 8.3k times · Source

A re-post of my previous question as I am not getting any satisfactory answer

The problem is as follows :

I have given my code in JSBin http://live.datatables.net/aqowib/2 for which I am not able to link to the sSwfPath properly. I am using codeiginter in my application so I am trying to load the files as follows:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
<script src="http://<?php base_url(); ?>/assets/js/jquery.dataTables.js" type="text/javascript"></script>
<script src="http://<?php base_url(); ?>/js/jquery.dataTables.columnFilter.js" type="text/javascript"></script>
<script src="http://<?php base_url(); ?>/media/js/ZeroClipboard.js" type="text/javascript"></script>
<script src="http://<?php base_url(); ?>/media/js/TableTools.js" type="text/javascript"></script>

And my script tag contains the following code:

$(document).ready(function(){
    var oTable = $('#datatables').dataTable({
        "sPaginationType":"full_numbers",
        "sDom": 'Tlfrtip',
        "oTableTools": {
            "sSwfPath": "<?php base_url();?>/media/swf/copy_cvs_xls_pdf.swf"
        },
        "sScrollX": "100%",
        "bScrollCollapse": true,
        "bAutoWidth": true,
        "aaSorting":[[0, "asc"]],
        "bJQueryUI":true
    }).columnFilter({
        aoColumns: [ null,
                     null,
                     { type: "select", values: [ 'male', 'female']  },
                     null,
                     null,
                     null,
                     null,
                     { type: "select", values: [ '1', '2', '3', '4', '5', '6', '7','8','9','10']  },
                     { type: "select", values: [ 'A', 'B', 'C']  },
                     null,
                     { type: "select", values: ['P', 'A'] },
                     null,
                     null,
                     null
            ]
    });
});

Everytime I am getting the 404 error saying that Unable to load SWF file - please check the SWF path

Please help me where am I wrong ? Thanks in advance.

Answer

NealCaffrey picture NealCaffrey · Apr 6, 2013

Ah, Got the solution !!

You just need to configure the sSwfPath URL in the TableTools.js file i.e.

CHANGE TableTools default settings for initialisation

Here I go :

TableTools.DEFAULTS = {
    "sSwfPath":         "http://localhost/codegen/media/swf/copy_cvs_xls_pdf.swf", <----------------- HERE IS WHERE I GOT STUCK 
    "sRowSelect":       "none",
    "fnPreRowSelect":   null,
    "fnRowSelected":    null,
    "fnRowDeselected":  null,
    "aButtons":         [ "copy", "csv", "xls", "pdf", "print" ]
};

Thanks :-)