当前位置:网站首页>Check and display one column in the known table column
Check and display one column in the known table column
2022-07-04 06:41:00 【Technology loving immortal】
import React, {
useEffect, useState} from 'react';
import {
Table,Checkbox,} from 'antd'
const columns = [
{
title: 'ID',
dataIndex: 'user_id',
key: 'user_id',
width: 100,
},
{
title: ' nickname ',
dataIndex: 'nickname',
key: 'nickname',
width: 150,
},
{
title: ' cell-phone number ',
dataIndex: 'phone',
key: 'phone',
width: 150,
},
{
title: ' balance ',
dataIndex: 'balance',
key: 'balance',
width: 150,
},
{
title: ' Platform service fee ',
dataIndex: 'service_charge',
key: 'service_charge',
width: 150,
},
{
title: ' Gender ',
dataIndex: 'sex',
key: 'sex',
width: 150,
},
{
title: ' Continuous login days ',
dataIndex: 'login_day',
key: 'login_day',
width: 200,
},
{
title: ' Maximum number of consecutive login days ',
dataIndex: 'login_bigday',
key: 'login_bigday',
width: 200,
},
{
title: ' Landing time ',
dataIndex: 'login_time',
key: 'login_time',
width: 200,
},
{
title: ' Time to join ',
dataIndex: 'join_time',
key: 'join_time',
width: 200,
},
{
title: ' state ',
dataIndex: 'status',
key: 'status',
width: 150,
},
]
// The drop-down
const plainOptions = [
{
label: 'ID', value:'user_id' },
{
label: ' nickname ', value: 'nickname'},
{
label: ' cell-phone number ', value:'phone' },
{
label: ' balance ', value: 'balance'},
{
label: ' Platform service fee ', value:'service_charge'},
{
label: ' Gender ', value: 'sex' },
{
label: ' Continuous login days ', value:'login_day' },
{
label: ' Maximum consecutive login days ', value: 'login_bigday'},
{
label: ' Landing time ', value:'login_time' },
{
label: ' Time to join ', value: 'join_time'},
{
label: ' state ', value:'status'},
];
const TableTreeChange = () => {
// Put the selected value Set it to be responsive to update the interface
const [selectColum,setSelectColum]=useState(columns)
// Originally selected by default value value
const [checkedList, setCheckedList] = useState(['user_id']);
// Put the multiple choices you checked into an array
const onChange = (list) => {
setCheckedList(list)
};
useEffect(() => {
console.log(checkedList,66666666666666666)
// Use double for Cycle the selected value And columns in the table key Values are linked
let newList=[]
for (let i = 0; i < checkedList.length; i++){
for (let j = 0; j < columns.length; j++){
if (checkedList[i] == columns[j].key) {
newList.push(columns[j]);
}
}
}
// The following part of the code is to add a fixed operation column to the table , If you don't need it, you can ignore
newList.push({
title: ' operation ',
key: 'action',
render: (text, record) => (
<span>
<a>edit</a>
</span>
),
width: 100,
fixed: 'right',
})
setSelectColum(newList)
}, [checkedList])
return (
<div>
<Table
columns={
selectColum}
pagination={
false}
/>
<Checkbox.Group options={
plainOptions} value={
checkedList} onChange={
onChange} />
</div>
);
};
export default TableTreeChange;
边栏推荐
- 雲原生——上雲必讀之SSH篇(常用於遠程登錄雲服務器)
- Operator < <> > fool test case
- tars源码分析之4
- Considerations for testing a website
- Learn about the Internet of things protocol WiFi ZigBee Bluetooth, etc. --- WiFi and WiFi protocols start from WiFi. What do we need to know about WiFi protocol itself?
- Internet of things protocol ZigBee ZigBee module uses the concept of protocol stack
- 关于IDEA如何设置快捷键集
- 树形dp
- [MySQL] introduction, function, creation, view, deletion and modification of database view (with exercises)
- selenium驱动IE常见问题解决Message: Currently focused window has been closed.
猜你喜欢
期末周,我裂开
P26-P34 third_ template
2022 wechat enterprise mailbox login entry introduction, how to open and register enterprise wechat enterprise mailbox?
Tree DP
Reading notes of Clickhouse principle analysis and Application Practice (4)
GoogleChromePortable 谷歌chrome浏览器便携版官网下载方式
selenium IDE插件下载安装使用教程
《ClickHouse原理解析与应用实践》读书笔记(4)
R statistical mapping - random forest classification analysis and species abundance difference test combination diagram
centos8安装mysql.7 无法开机启动
随机推荐
Realize IIC data / instruction interaction with micro batg135
Selection (022) - what is the output of the following code?
How does the recv of TCP socket receive messages of specified length?
Stc8h development (XII): I2C drive AT24C08, at24c32 series EEPROM storage
同一个job有两个source就报其中一个数据库找不到,有大佬回答下吗
Common JS tool Libraries
【GF(q)+LDPC】基于二值图GF(q)域的规则LDPC编译码设计与matlab仿真
2022 wechat enterprise mailbox login entry introduction, how to open and register enterprise wechat enterprise mailbox?
The sorting in C language realizes the number sorting method from small to large
tars源码分析之8
Mysql 45讲学习笔记(七)行锁
Selection (023) - what are the three stages of event propagation?
Fundamentals of SQL database operation
17-18. Dependency scope and life cycle plug-ins
C réaliser des jeux de serpents gourmands
Tar source code analysis Part 7
[Android reverse] function interception (CPU cache mechanism | CPU cache mechanism causes function interception failure)
tars源码分析之1
what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!
Mysql 45讲学习笔记(十一)字符串字段怎么加索引