el-table-draggable
Version:
make el-table draggable, support row, column, expanded, sortable.js
115 lines (77 loc) • 2.18 kB
Markdown
[中文文档](./README-ZH.md)
Let el-table support sortable.js
[](https://www.mizuka.top/el-table-draggable/)
- support almost all options in `sortablejs`
- support drag from one to another table
- support treeTable
- support vetur
- support onMove
- support drag into an empty `el-table`
- Drag rows
- Drag columns(>1.1.0)
- Drag tree(>1.2.0)
- disable move by set onMove(>1.3.0)
- Set handle for drag
- Set group
- ...other option in sortable.js
- event input, after the change of all
## Install
### use npm or yarn
```bash
yarn add el-table-draggable
npm i -S el-table-draggable
```
## Usage
```js
import ElTableDraggable from "el-table-draggable";
export default {
components: {
ElTableDraggable,
},
};
```
```html
<template>
<el-table-draggable>
<el-table row-key></el-table>
</el-table-draggable>
</template>
```
the wrapper tag of el-table, default is `div`
support drag column
set onMove callback
```javascript
onMove: function (/**Event*/evt, /**Event*/originalEvent, domInfo) {
// Example: https://jsbin.com/nawahef/edit?js,output
evt.dragged; // dragged HTMLElement
evt.draggedRect; // DOMRect {left, top, right, bottom}
evt.related; // HTMLElement on which have guided
evt.relatedRect; // DOMRect
evt.willInsertAfter; // Boolean that is true if Sortable will insert drag element after target by default
originalEvent.clientY; // mouse position
domInfo.dragged // the origin dom info of dragged tr, like parent domInfo, level, data, and it's index
domInfo.related // like dragged
// return false; — for cancel
// return -1; — insert before target
// return 1; — insert after target
},
```
[](https://github.com/SortableJS/Sortable#options)
data or cloumn after change
[](https://github.com/SortableJS/Sortable#options), the option start with `on`, Example`onSort => @sort`
- [ ] Tree Table
[](https://buymeacoffee.com/mizukawu)