Is there a problem with DataTables and Bootstrap?

Is there a problem with DataTables and Bootstrap?

marcwmarcw Posts: 18Questions: 4Answers: 0

I've used DataTables before- I've tried to use it again in a new site I'm working on - and it just doesn't seem to grab the table.

I'm sure I'm missing something simple/stupid, but the site is built with Bootstrap (not by me) and I'm wondering if this is an issue?

URL is http://test.armymuseums.org.uk/amot-t-admin/a-kew-report-x

Debug: http://debug.datatables.net/ijerax

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,687Questions: 1Answers: 10,500 Site admin

    If you look at the console in your browser you will see:

    Uncaught SyntaxError: Unexpected end of input

    (or something similar if you are using something other than Chrome).

    Looks like your are missing a } ); to close the document ready function where you create the DataTable.

    Allan

  • marcwmarcw Posts: 18Questions: 4Answers: 0

    D'oh! I knew it would be something simple/stupid!

    OK- that's better- it's started doing things to the table, like putting the sort icons in the headers. But it's still not sorting/seaching.

    The console is saying:

    Uncaught TypeError: Cannot read property 'fnSetData' of undefined
    http://test.armymuseums.org.uk/lib/datatables/js/jquery.datatables.js:820

    Hmm. I wonder if I have the latest version?

  • marcwmarcw Posts: 18Questions: 4Answers: 0
    edited November 2014

    Hmm.

    I've changed the includes to point at the CDN versions, to make sure I've got the latest version. It still doesn't work.

    Another thing I've noticed is that it's applied the sort buttons to only some of the fields- the first four (L->R). I can't see anything in my code that specifies that (either way, to be honest).

  • allanallan Posts: 63,687Questions: 1Answers: 10,500 Site admin
    Answer ✓

    Your aoColumns defines four columns, but the HTML table has six columns.

    DataTables 1.10 will automatically detect the html type, so I would suggest just removing your aoColumns entirely.

    Allan

  • marcwmarcw Posts: 18Questions: 4Answers: 0
    edited November 2014

    Aha! My bad- that's done the trick!

    I think I'd forgotten what that option did, to be honest. It's a problem when you don't use stuff all the time.

    Another triumph for datatables.

    I may start to play with some of the new plugins now....

This discussion has been closed.