Newbie question: Datatables is loaded but options/settings not working
Newbie question: Datatables is loaded but options/settings not working
scotsscripts
Posts: 11Questions: 5Answers: 0
<script type="text/javascript" class="init">
$('#article-table').DataTable( {
ColumnDefs:
[
{
targets: [ 6 ],
orderData: 5
},
{
targets: [ 5 ],
visible: false,
searchable: false
}
]
} );
</script>
Do you see any issues with the code above?
I'm trying to hide column 5 and sort column 6 based on column 5. Neither of which is working.
I've tried it with double quotes around the option words (the examples and docs show it both ways) but still no love.
Datatables is loaded and working; column sorting works and other options such as page length and whatnot work.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Should be:
With a lower case
c
. The parameters are case sensitive.Kevin
Thanks for responding. I changed it to columnDefs but no change in the behavior; the hidden column is still visible and it's still sorting on col 6 instead of 5. Any other ideas?
To be clear, the first column is column 0, and so on
Also, jquery scripts are typically put in jquery ready to make sure they don't fire off before the page is loaded so...
Ah, that did the trick, thank you very much for taking the time to help, I appreciate it!