admin管理员组

文章数量:1332325

I am attempting to use datatables' FixedColumns plugin. Nothing is working. I have dropped down to the example code straight off of the website, here:

$(document).ready( function () {
    var oTable = $('#example').dataTable( {
        "sScrollX": "100%",
        "sScrollXInner": "150%",
        "bScrollCollapse": true
    } );

    new FixedColumns( oTable );
} );

Script tags:

<script type="text/javascript" src="http://address/testbed/js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="http://address/testbed/js/datatables.js"></script>
<script type="text/javascript" src="http://address/testbed/js/fixedcolumns.js"></script>

All scripts are loading fine according to chrome. The error I am getting is "Uncaught ReferenceError: FixedColumns is not defined."

jQuery 1.11.0

datatables 1.9.4

FixedColumns 3.0.1-dev (I've tried various versions, this is the latest releast off github)

What's up?

I am attempting to use datatables' FixedColumns plugin. Nothing is working. I have dropped down to the example code straight off of the website, here:

$(document).ready( function () {
    var oTable = $('#example').dataTable( {
        "sScrollX": "100%",
        "sScrollXInner": "150%",
        "bScrollCollapse": true
    } );

    new FixedColumns( oTable );
} );

Script tags:

<script type="text/javascript" src="http://address/testbed/js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="http://address/testbed/js/datatables.js"></script>
<script type="text/javascript" src="http://address/testbed/js/fixedcolumns.js"></script>

All scripts are loading fine according to chrome. The error I am getting is "Uncaught ReferenceError: FixedColumns is not defined."

jQuery 1.11.0

datatables 1.9.4

FixedColumns 3.0.1-dev (I've tried various versions, this is the latest releast off github)

What's up?

Share Improve this question edited Apr 1, 2014 at 17:58 John Chrysostom asked Apr 1, 2014 at 17:51 John ChrysostomJohn Chrysostom 3,9831 gold badge42 silver badges55 bronze badges 2
  • What does your script tags look like? Are the files loaded? My guess is you are missing the FixedColumns.js – epascarello Commented Apr 1, 2014 at 17:56
  • Added the script tags. That's definitely not the issue though. Chrome reports they're all successfully loaded. – John Chrysostom Commented Apr 1, 2014 at 17:59
Add a ment  | 

2 Answers 2

Reset to default 7

You should use:

new $.fn.dataTable.FixedColumns( oTable );

which is what the documentation actually says for me too.

The "constructor" FixedColumns is only defined in the IIFE which wraps the plugin and exports as $.fn.dataTable.FixedColumns

Try this

var oTable = $('#example').dataTable( {
        "sScrollX": "100%",
        "sScrollXInner": "150%",
        "bScrollCollapse": true
    } );


new $.fn.dataTable.FixedColumns( oTable , {
            leftColumns: 3 //specifies how many left columns should be fixed.
        });

本文标签: javascriptDataTables FixedColumn quotUncaught ReferenceError FixedColumns is not definedquotStack Overflow