baker
baker

Reputation: 241

Sorting a tables first column after using jQuery UI's sortable?

I got a table which uses jQuery UI's sortable. The first column contains the order number of each row. How do I automatically sort the numbers (in ascending order) in the first column when I sort the rows? This means that only the numbers in the first column will be sorted.

Thanks in advance!

Upvotes: 2

Views: 1643

Answers (1)

Deniss Kozlovs
Deniss Kozlovs

Reputation: 4841

var position = 1;

$('table tbody tr').each(function () {
    $('td:first', $(this)).text(position);
    position += 1;
});

You can put this function that occurs when sorting is done (it's "stop" for sortables UI)

Upvotes: 2

Related Questions