当前位置:网站首页>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;
边栏推荐
- Fundamentals of SQL database operation
- Shopping malls, storerooms, flat display, user-defined maps can also be played like this!
- Overview of convolutional neural network structure optimization
- The width of the picture in rich text used by wechat applet exceeds the problem
- CORS is not intended to protect API endpoints - nikofischer
- Variables d'environnement personnalisées uniapp
- Uniapp custom environment variables
- C實現貪吃蛇小遊戲
- Another company raised the price of SAIC Roewe new energy products from March 1
- What is the sheji principle?
猜你喜欢
【MySQL】数据库视图的介绍、作用、创建、查看、删除和修改(附练习题)
双色球案例
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?
Distributed cap theory
Download kicad on Alibaba cloud image station
Overview of convolutional neural network structure optimization
【GF(q)+LDPC】基于二值图GF(q)域的规则LDPC编译码设计与matlab仿真
【问题记录】03 连接MySQL数据库提示:1040 Too many connections
2022 wechat enterprise mailbox login entry introduction, how to open and register enterprise wechat enterprise mailbox?
Inputstream/outputstream (input and output of file)
随机推荐
Selection (023) - what are the three stages of event propagation?
Learning multi-level structural information for small organ segmentation
Overview of convolutional neural network structure optimization
uniapp 自定義環境變量
Common JS tool Libraries
8. Factory method
微信小程序使用rich-text中图片宽度超出问题
1、 Relevant theories and tools of network security penetration testing
List of top ten professional skills required for data science work
what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!
采用中微BATG135实现IIC数据/指令交互
tars源码分析之1
2022 where to find enterprise e-mail and which is the security of enterprise e-mail system?
《ClickHouse原理解析与应用实践》读书笔记(4)
leetcode 310. Minimum Height Trees
Mysql 45讲学习笔记(十三)表数据删掉一半,表文件大小不变
Uniapp custom environment variables
leetcode825. 适龄的朋友
tars源码分析之5
How to use multithreading to export excel under massive data? Source code attached!