JQuery plugin for dragging and dropping rows in a table
npm install tabledndTableDnD is easy to install:
```
npm install --save tablednd`
or`
yarn add tablednd`
or`
bower install https://github.com/isocra/TableDnD.git`
Alternatively you can simply reference from CDNJS:html``
orhtml`
You'll also need to include jQuery before you include this plugin (so that jQuery is defined).
---
Let's create a simple table. The HTML for the table is very straight forward (no Javascript, pure HTML, we haven't added thead or tbody elements, but it works fine with these too):
`html`
1 One some text
2 Two some text
3 Three some text
4 Four some text
5 Five some text
6 Six some text $(document).ready(...)
To add in the "draggability" all we need to do is add a line to the function as follows:`html`tableDnD`. If you try this, you'll see that the rows are now draggable.
Basically we get the table element and call
In the example above we're not setting any parameters at all so we get the default settings. There are a number of parameters you can set in order to control the look and feel of the table and also to add custom behaviour on drag or on drop. The parameters are specified as a map in the usual way and are described the full documentation:
You can also play and experiment with TableDnD using this jsFiddle. Here you get the documentation, plus live examples.