Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help need help with drag & drop of columns into tables #210

Open
jcarlos66 opened this issue Jan 29, 2021 · 1 comment
Open

Help need help with drag & drop of columns into tables #210

jcarlos66 opened this issue Jan 29, 2021 · 1 comment

Comments

@jcarlos66
Copy link

Hi Phuoc, I am not an expert programmer, I am an amateur and for a personal project I need to make a small modification to this code https://htmldom.dev/drag-and-drop-table-column/

the code works very well, I just need that moving the table columns is not done through the text, but by dragging an icon inside the TH something like that. Header name .

In other words, only if I hover over the icon and drag the icon can the column move as it does now, but if the text or any other element within the TH is dragged, it will not trigger the drag event.
Could you help me?
thanks

@kl3sk
Copy link

kl3sk commented May 21, 2021

Did you found a solution ? I manage to have the same behavior, this should work:

Assuming a element (ex: <span>) inside the <th> with a class .handle

Update like this :

draggingColumnIndex = [].slice.call(table.querySelectorAll('.handle')).indexOf(e.target)
....
table.querySelectorAll('th > .handle').forEach(function (headerCell) { 
....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants