3

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.

Community
  • 1
  • 1
NealCaffrey
  • 273
  • 3
  • 10
  • 22

2 Answers2

1

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 :-)

NealCaffrey
  • 273
  • 3
  • 10
  • 22
  • 1
    Wouldn't that mean that your `` is returning a wrong value? – berbt Jun 30 '14 at 14:41
  • Dear NealCaffrey, how can we use the sSwfPath in laravel 4.2 page? Please give suggestion – sujivasagam Jul 15 '15 at 09:10
  • Although this might have solved your problem, it is not what caused the problem. You forgot to use echo and so berbt was right. The part `` does not return a value. See the answer of Vishav B Kaith. – RWC Nov 25 '15 at 14:09
  • Additional: And it will only work if you have got your javascript code in your PHP file. If not, you have to make it avilable to your javascript files by assigning it to a global Javascript variable like this: `echo ' – RWC Nov 25 '15 at 14:30
1

No need to write full path Just place echo before base_url :) Change

<?php base_url();?>

To

<?php echo base_url();?>
martin clayton
  • 76,436
  • 32
  • 213
  • 198
Vishav B Kaith
  • 139
  • 1
  • 5
  • This DOES provide an answer to the question. The author asked where he was wrong, and this is where he was wrong. It almost certainly solves his problem – RWC Nov 25 '15 at 14:05