How to use index column with data source

How to use index column with data source

mikejobsmikejobs Posts: 4Questions: 1Answers: 0

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

  • mikejobsmikejobs Posts: 4Questions: 1Answers: 0

    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

  • mikejobsmikejobs Posts: 4Questions: 1Answers: 0

    Also used this as my first column

    { "data": null, "searchable": false, "orderable": false },

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947
    Answer ✓

    Looks like you are running into the issue in the FAQ:
    https://datatables.net/faqs/index#api

    Change var t = $('#example').dataTable( { to var t = $('#example').DataTable( {. Not the capital D in DataTable.

    Plus you will need the { "data": null, "searchable": false, "orderable": false }, that you placed in column 0.

    Kevin

  • mikejobsmikejobs Posts: 4Questions: 1Answers: 0

    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.

This discussion has been closed.