-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
请教defaultHidden 怎么实现对BasicTable组件二级表头的某列隐藏 #3559
Comments
16 tasks
提了个 pr(https://github.com/vbenjs/vue-vben-admin/pull/3561/files)尝试优化 src\components\Table\src\hooks\useColumns.ts 解决上述问题(不影响 setColumns、getTableColumns)
根据官方 demo 修改的测试用例:
<template>
<div class="p-4">
<BasicTable @register="registerTable">
<template #toolbar>
<a-button type="primary" @click="changeColumns">
隐藏一级表头“ID"、二级表头“结束时间”
</a-button>
</template>
</BasicTable>
</div>
</template>
<script lang="ts" setup>
import { BasicTable, useTable } from '@/components/Table';
import type { BasicColumn } from '@/components/Table';
import { cloneDeep } from 'lodash-es';
import { demoListApi } from '@/api/demo/table';
const defaultColumns: BasicColumn[] = [
{
title: 'ID',
dataIndex: 'id',
width: 200,
},
{
title: '地址',
dataIndex: 'address',
sorter: true,
children: [
{
title: '开始时间',
dataIndex: 'beginTime',
width: 120,
},
{
title: '结束时间',
dataIndex: 'endTime',
width: 120,
children: [
{
title: '三级表头',
dataIndex: 'beginTime',
width: 120,
},
],
},
] as BasicColumn[],
},
];
const [registerTable, { setColumns }] = useTable({
title: '多级表头示例',
api: demoListApi,
columns: defaultColumns,
showTableSetting: true,
});
function changeColumns() {
let changedColumns = cloneDeep(defaultColumns);
// 隐藏一级表头“ID"
changedColumns.find((o) => o.dataIndex === 'id')!.defaultHidden = true;
// 隐藏二级表头“结束时间”
changedColumns
.find((o) => o.dataIndex === 'address')!
.children!.find((o) => o.dataIndex === 'endTime')!.defaultHidden = true;
setColumns(changedColumns);
}
</script>
|
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Subject of the feature
我想实现控制二级表头隐藏显示 列表columns已更改 但页面无反应
重写 src/components/Table/src/hooks/useColumns.ts 方法setColumns
重写
src/components/Table/src/components/settings/ColumnSetting.vue 方法getTableColumns
在列设置(table右上角小弹框) 初始化 显示所有的一级表头和二级表头
Describe your issue here.
Problem
If the feature requests relates to a problem, please describe the problem you are trying to solve here.
Expected behaviour
期望点击列设置实现对BaseTable组件二级表头列控制显示与隐藏
What should happen? Please describe the desired behaviour.
Alternatives
What are the alternative solutions? Please describe what else you have considered?
想知道实现二级列表隐藏还需要修改哪些地方
The text was updated successfully, but these errors were encountered: