使用 vxe-table 实现分组表头子列之间进行拖拽,限制允许子列进行拖拽
安装
npm install vxe-pc-ui@4.3.55 vxe-table@4.10.0
// ...
import VxeUI from 'vxe-pc-ui'
import 'vxe-pc-ui/lib/style.css'
import VxeUITable from 'vxe-table'
import 'vxe-table/lib/style.css'
// ...
createApp(App).use(VxeUI).use(VxeUITable).mount('#app')
// ...
效果
通过 column-drag-config.isPeerDrag 启用同层级拖拽
<template>
<div>
<vxe-grid v-bind="gridOptions"></vxe-grid>
</div>
</template>
<script>
export default {
data () {
const gridOptions = {
border: true,
columnConfig: {
drag: true
},
columnDragConfig: {
isPeerDrag: true
},
columns: [
{ field: 'name', title: 'Name' },
{ field: 'nickname', title: 'Nickname' },
{
title: '分组1',
field: 'group1',
children: [
{ field: 'role', title: 'Role' },
{ field: 'sex', title: 'Sex' }
]
},
{
title: '分组6',
field: 'group6',
children: [
{
title: '分组9',
field: 'group9',
children: [
{ field: 'age', title: 'Age' },
{ field: 'address', title: 'Address' }
]
}
]
}
],
data: [
{ id: 10001, name: 'Test1', role: 'Develop', sex: 'Man', age: 28, address: 'test abc' },
{ id: 10002, name: 'Test2', role: 'Test', sex: 'Women', age: 22, address: 'Guangzhou' },
{ id: 10003, name: 'Test3', role: 'PM', sex: 'Man', age: 32, address: 'Shanghai' },
{ id: 10004, name: 'Test4', role: 'Designer', sex: 'Women', age: 24, address: 'Shanghai' }
]
}
return {
gridOptions
}
}
}
</script>
https://gitee.com/x-extends/vxe-table
标签:子列,title,vxe,field,table,拖拽,name From: https://www.cnblogs.com/qaz666/p/18645452