Skip to content

guolaopi/element-plus-table-dragable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

element-plus-table-dragable

A directive what used sortablejs to add drag support for element-plus's table component base on vue3.

Useage

<template>
    <el-table 
        v-dragable="dragOptions" 
        :data="data"
    >
    </el-table>
</template>

<script setup>
import { vDragable } from "element-plus-table-dragable"; 

const dragOptions = [
    {
        selector: "thead tr", // add drag support for column
        option: { // sortablejs's option
            animation: 150,
            onEnd: (evt) => {
                /* you can define a 'columns' ref 
                and use v-for render it in table's slot. 
                then you can change index of the item in 'column' here 
                to implement drag column to sort */
                console.log(evt.oldIndex, evt.newIndex);
            },
        },
    },
    {
        selector: "tbody", // add drag support for row
        option: { // sortablejs's option
            animation: 150,
            onEnd: (evt) => {
                console.log(evt.oldIndex, evt.newIndex);
            },
        },
    },
];
</script> 

here is the demo link: element-plus-table-dragable-demo

About

A directive to add drag support for element-plus's table component base on vue3.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published