Is there a problem with DataTables and Bootstrap?
Is there a problem with DataTables and Bootstrap?
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
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
If you look at the console in your browser you will see:
(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
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?
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).
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 youraoColumns
entirely.Allan
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....