Move table columns around with drag & drop
I've created a data table component where you can move around the order of the columns using the drag and drop api.
Specifically, I am using
e.dataTransfer.setData
to set the index on an ondragstart
and read it during the ondrop
event.
It works as expected, at least on the first try, after that the behaviour becomes weird because it will always use the old index and not the new ordering.
I've tried using a Index
instead of a For
, this solves the index issue but then the data will be matched with the wrong column.
One way to work around this is to just pass the index in manually like this: {each:()=>props.headers().map((h,i)=>[h,i])}
.
Might there be a better option?0 Replies