How to sort a list using the sortable.js library? https://sortablejs.github.io/Sortable/
I set sortable_container(sortable_employees id) on the tr attribute. This works great. But how to sort td in tbody at the same time?
Please see gif. Tbody is not sortable. How to create a table to drag and drop header cells and body cells. Or how can I set up sortable.js to do this for me?
Check the sample code:
const el = document.getElementById('sortable_employees'); const sortable = new Sortable(el, { animation: 150, ghostClass: 'bg-blue-200', });
https://jsfiddle.net/mateuszbialowas/ds5bfj7v/27/
P粉7454121162024-02-04 00:12:31
You can try this div method.
Sortable.create(document.getElementById('draggableDivTable'), { sort: true, handle: '.columnHeader', animation: 150 });column 0c0 r0c0 r1c0 r2c0 r3c0 r4c0 r5column 1c1 r0c1 r1c1 r2c1 r3c1 r4c1 r5column 2c2 r0c2 r1c2 r2c2 r3c2 r4c2 r5
https://codepen.io/jlapinski/pen/ZXYERN