Finally, you are able to drag and sort your table as you want.

Try out the demo!

Inspiration

Table-dragger is a minimalist plain Javascript library for building reorderable drag-and-drop table.

Install

You can get it on npm.

npm install table-dragger --saveCopy the code

or

<script src="../node_modules/table-dragger/dist/table-dragger.min.js"></script>Copy the code

options.mode

  • Setting mode to column, user drag and sort columns of table
  • Setting mode to row, user drag and sort rows of table
  • Setting mode to free, user drag rows or columns, depending on the direction of the mouse movement after tapping. Notice you have to specify dragHandler in free mode.

options.onlyBody

  • Setting onlyBody to true in row mode, user can only lift rows in tbody.

API

The tableDragger method returns a tiny object with a concise API. We’ll refer to the API returned by tableDragger as dragger

dragger.dragging

This property will be true whenever an element is being dragged.

License

MIT