Skip to content
Discussion options

You must be logged in to vote

Here is my drag-and-drop implementation (v.8-alpha). My implementation uses only onChange method not onEnd. The behavior is that you drag&drop only the th elements.

I share the only necessary part:

  let columnBeingDragged: number;

  const onDragStart = (e: DragEvent<HTMLElement>): void => {
    columnBeingDragged = Number(e.currentTarget.dataset.columnIndex);
  };

  const onDrop = (e: DragEvent<HTMLElement>): void => {
    e.preventDefault();
    const newPosition = Number(e.currentTarget.dataset.columnIndex);
    const currentCols = instance.getVisibleLeafColumns().map((c) => c.id);
    const colToBeMoved = currentCols.splice(columnBeingDragged, 1);

    currentCols.splice(newPosition, 0

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by rodolphoasb
Comment options

You must be logged in to vote
2 replies
@galnir
Comment options

@KevinVandy
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants