Moving column of table in RubaXa' sortable

156 Views Asked by At

I'm not sure if this is the right place for this, but I was wondering if there is anyway to move the entire column of a table by moving the th using RubaXa's sortable library. I created a table and made the header sortable, but I'm not sure how to tie in the table body to the header.

I had to have code to pose jsfiddle.

https://jsfiddle.net/tt0rm0rt/1/

I want the whole column to update if I move the price, instead of just the header.

Thank you!

1

There are 1 best solutions below

0
On

We are trying to do the same thing here in our team. In the sortable.js e have a function called onEnd. We receive the evt.oldIndex and the evt.newIndex. After this we only change the index of the column body.

You sort the head, get the last element position and the new position and than you change the indexes of the body children.