Anyone initializing datatables to sort by the last column?

Anyone initializing datatables to sort by the last column?

iraxirax Posts: 4Questions: 2Answers: 0

I am trying a negative column index, but that seems to not get processed into the right column offset, and causes an exception.

My code:

$('.generic-table').DataTable({
        'order': [[-1, 'desc']]
    });

Answers

  • iraxirax Posts: 4Questions: 2Answers: 0

    Could not get the initialization to work. Ended up ordering after init:

        $('.generic-table').DataTable({
        });
        
        $('.generic-table').DataTable().columns(-1).order('desc').draw();
    
  • ashl1ashl1 Posts: 18Questions: 5Answers: 1

    I'm interested in the case you are working on where you don't know the number of columns. Why using count-1 is harder?

This discussion has been closed.