Changing data-order after initialization?

Changing data-order after initialization?

NeekasaNeekasa Posts: 8Questions: 1Answers: 0
edited May 2014 in DataTables 1.10

Hello :)

I was wondering if there was a way of Re-initializing the sorting after changing a data-order attribute on a table cell?

$('#'+userID).children('td:eq(2)').attr('data-order', statusord);

I use draw() after but it doesn't seem to do anything.

Thanks for the help!

This question has an accepted answers - jump to answer

Answers

  • NeekasaNeekasa Posts: 8Questions: 1Answers: 0

    I've put a solution in to just destroy() the table then re-initialize it, which seems to be working great.

    Sorry for the brain meltdown (too little sleep is bad...)

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    edited May 2014 Answer ✓

    destroy() is the heavy handed approach ;-). It will work, but it is better to simply call row().invalidate(). Then when you call draw, or when DataTables next sorts the data, it will read the new value, since the old one has been invalidated. This is far more efficient.

    Regards,
    Allan

  • NeekasaNeekasa Posts: 8Questions: 1Answers: 0

    Thank you for your response Allan!

    It's working wonders, the new API is brilliant, thank you for updating DT so much :)

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Fantastic to hear. Thanks for the kind words :-)

    Allan

This discussion has been closed.