Uncaught TypeError: undefined is not a function

Uncaught TypeError: undefined is not a function

gboogaartgboogaart Posts: 1Questions: 1Answers: 0

I'm trying to initialize the fixedColumns, and get this error back. I have just upgraded to dataTables 1.10 and fixedColumns v.3.01. I've completely stripped everything and left with this:
var table = $('result-table').dataTable({ "scrollX": true, })
new $.fn.dataTable.fixedColumns(table);

In the 'old' (new 2 weeks old haha) version it was a bootstrap issue that could be resolved by doing:
var frozen = new FixedColumns(table) ({});

Is there a fancy way to make fixedColumns and Bootstrap work together in this version?

Answers

  • seb33gelseb33gel Posts: 25Questions: 3Answers: 1

    Try to replace dataTable() by DataTable() for initialisation.

  • dobie_gillisdobie_gillis Posts: 2Questions: 0Answers: 0

    I'm getting TypeError: undefined is not a function with DataTables 1.10.2, and I've tried both:

    $('#table').dataTable();
    

    and:

    $('#table').DataTable();
    
  • mRendermRender Posts: 151Questions: 26Answers: 13

    What are your includes for the datatable js files?

  • dobie_gillisdobie_gillis Posts: 2Questions: 0Answers: 0

    Just using the same one from the datatables install guide:

    <script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.2/js/jquery.dataTables.js"></script>
    

    I fixed the problem by including datatables immediately after jQuery. I had some other jQuery libraries I was including between jQuery and DataTables.

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    new $.fn.dataTable.fixedColumns(table);

    Should be:

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

    It is a constructor, so by general convention it gets a capital.

    Is there an error in the documentation somewhere that suggests it should be lowercase?

    Allan

  • docbobdocbob Posts: 1Questions: 0Answers: 0

    In the same way you used an upper-case 'D' in 'DataTable' here,

    $('#table').DataTable();

    you need to do the same here,

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

    should be

    new $.fn.DataTable.FixedColumns(table);

    Bob

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    That should not be the case with the latest version of FixedColumns. $.fn.dataTable.FixedColumns === $.fn.DataTable.FixedColumns.

    It probably was true with old v2 releases, but not with the current release.

    Allan

  • mkdmkd Posts: 7Questions: 3Answers: 0

    Hello allan,

    For the following line, I get the error below:
    new $.fn.dataTable.FixedColumns(table);

    Uncaught TypeError: $.fn.dataTable.FixedColumns is not a function(anonymous function) @ (index):36m.Callbacks.j @ jquery.js:2m.Callbacks.k.fireWith @ jquery.js:2m.extend.ready @ jquery.js:2J @ jquery.js:2

    Could you please help me with this? I am using the latest version of DT.

    Thanks,

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    Sounds like you have not included the FixedColumns library. Can you link to the page so we can confirm if that is the issue please.

    Allan

This discussion has been closed.