Vxe UI vue vxe-table 表格中使用下拉表格,单元格渲染下拉表格

Vxe UI vue vxe-table 表格中使用下拉表格,单元格渲染下拉表格

单元格中渲染下拉表格,需要使用到 vxe-table-select 这个组件,在 vxe-table 4.7+ 中使用非常简单,只需要配置好渲染器数据源就可以。

支持单选

也可以多选

代码

html 复制代码
<template>
  <div>
    <vxe-grid v-bind="gridOptions"></vxe-grid>
  </div>
</template>

<script setup>
import { reactive } from 'vue'

const currUserEditRender = reactive({
  name: 'VxeTableSelect',
  props: {
    columns: [
      { field: 'label', title: 'Name' },
      { field: 'role', title: 'Role' },
      { field: 'sex', title: 'Sex' },
      { field: 'address', title: 'Address' }
    ]
  },
  options: [
    { value: 10001, label: 'Test1', role: 'Develop', sex: 'Man', age: 28, address: 'test abc' },
    { value: 10002, label: 'Test2', role: 'Test', sex: 'Women', age: 22, address: 'Guangzhou' },
    { value: 10003, label: 'Test3', role: 'PM', sex: 'Man', age: 32, address: 'Shanghai' },
    { value: 10004, label: 'Test4', role: 'Designer', sex: 'Women', age: 24, address: 'Shanghai' }
  ]
})

const currUserListEditRender = reactive({
  name: 'VxeTableSelect',
  props: {
    multiple: true,
    columns: [
      { field: 'label', title: 'Name' },
      { field: 'role', title: 'Role' },
      { field: 'sex', title: 'Sex' },
      { field: 'address', title: 'Address' }
    ]
  },
  options: [
    { value: 10001, label: 'Test1', role: 'Develop', sex: 'Man', age: 28, address: 'test abc' },
    { value: 10002, label: 'Test2', role: 'Test', sex: 'Women', age: 22, address: 'Guangzhou' },
    { value: 10003, label: 'Test3', role: 'PM', sex: 'Man', age: 32, address: 'Shanghai' },
    { value: 10004, label: 'Test4', role: 'Designer', sex: 'Women', age: 24, address: 'Shanghai' }
  ]
})

const gridOptions = reactive({
  border: true,
  editConfig: {
    trigger: 'click',
    mode: 'row'
  },
  columns: [
    { type: 'seq', width: 70 },
    { field: 'name', title: 'Name', minWidth: 200, editRender: { name: 'VxeInput' } },
    { field: 'currUser', title: '下拉树单选', width: 200, editRender: currUserEditRender },
    { field: 'currUserList', title: '下拉树多选', width: 200, editRender: currUserListEditRender }
  ],
  data: [
    { id: 10001, name: 'Test1', role: 'Develop', currUser: null, currUserList: [] },
    { id: 10002, name: 'Test2', role: 'Test', currUser: 10002, currUserList: [10001] },
    { id: 10003, name: 'Test3', role: 'PM', currUser: null, currUserList: [10001, 10004] }
  ]
})

</script>

github https://github.com/x-extends/vxe-table
gitee

相关推荐
大猩猩X1 天前
vxe-gantt vue table 甘特图子任务多层级自定义模板用法
vue.js·甘特图·vxe-table·vxe-ui
韩曙亮1 天前
【Web APIs】元素可视区 client 系列属性 ( client 属性简介 | 常用的 client 属性 | 使用场景 | 代码示例 )
前端·javascript·css·css3·bom·client·web apis
不一样的少年_1 天前
【错误监控】别只做工具人了!手把手带你写一个前端错误监控 SDK
前端·javascript·监控
艾小码1 天前
还在手动处理页面跳转?掌握Vue Router 4,你的导航效率翻倍!
前端·javascript·vue-router
xxy-mm1 天前
Javascript 中的继承
开发语言·javascript·ecmascript
1024肥宅1 天前
手写 EventEmitter:深入理解发布订阅模式
前端·javascript·eventbus
吃好喝好玩好睡好1 天前
基于Flutter与OpenHarmony ArkUI组件互通的Electron桌面应用UI优化方案
flutter·ui·electron
EveryPossible1 天前
google搜索框
vue.js
3秒一个大1 天前
HTML5 与 JavaScript 中的二进制数据处理:ArrayBuffer 与 TextEncoder/Decoder 实践
javascript
purpleseashell_Lili1 天前
如何学习 AG-UI 和 CopilotKit
javascript·typescript·react