How to use index column with data source
How to use index column with data source
I am trying to use an index column that automatically shows row counter based on sort.
I am using this example: https://datatables.net/examples/api/counter_columns.html
But I can't figure out how to get it to work when using "columns" as well.
This is what my code looks like: https://hastebin.com/egegisuraq.js
I believe the issue is related to the fact I specified my columns with "columns" but I don't know how to specify a placeholder for this rendered column that represents the row ID based on current sort. I tried using "null" but that did not work.
This question has an accepted answers - jump to answer
Answers
I checked the console and I noticed this error:
jQuery.Deferred exception: t.on(...).draw is not a function TypeError: t.on(...).draw is not a function
Also used this as my first column
{ "data": null, "searchable": false, "orderable": false },
Looks like you are running into the issue in the FAQ:
https://datatables.net/faqs/index#api
Change
var t = $('#example').dataTable( {
tovar t = $('#example').DataTable( {
. Not the capitalD
in DataTable.Plus you will need the
{ "data": null, "searchable": false, "orderable": false },
that you placed in column 0.Kevin
Thank you Kevin! I didn't even notice the caps, I didn't know there were two similar classes.
I plugged at this for a while trying all sorts of things, that was the last thing to expect.