当前位置:网站首页>Cochez une colonne d'affichage dans une colonne de tableau connue
Cochez une colonne d'affichage dans une colonne de tableau connue
2022-07-04 06:41:00 【L'immortel de l'amour de la technologie】
import React, {
useEffect, useState} from 'react';
import {
Table,Checkbox,} from 'antd'
const columns = [
{
title: 'ID',
dataIndex: 'user_id',
key: 'user_id',
width: 100,
},
{
title: 'Un surnom.',
dataIndex: 'nickname',
key: 'nickname',
width: 150,
},
{
title: 'Numéro de téléphone portable',
dataIndex: 'phone',
key: 'phone',
width: 150,
},
{
title: 'Solde',
dataIndex: 'balance',
key: 'balance',
width: 150,
},
{
title: 'Frais de service de la plateforme',
dataIndex: 'service_charge',
key: 'service_charge',
width: 150,
},
{
title: 'Sexe',
dataIndex: 'sex',
key: 'sex',
width: 150,
},
{
title: 'Jours de connexion consécutifs',
dataIndex: 'login_day',
key: 'login_day',
width: 200,
},
{
title: 'Nombre maximum de jours consécutifs de connexion',
dataIndex: 'login_bigday',
key: 'login_bigday',
width: 200,
},
{
title: 'Heure de connexion',
dataIndex: 'login_time',
key: 'login_time',
width: 200,
},
{
title: 'Temps d'ajout',
dataIndex: 'join_time',
key: 'join_time',
width: 200,
},
{
title: 'Statut',
dataIndex: 'status',
key: 'status',
width: 150,
},
]
//Descendez.
const plainOptions = [
{
label: 'ID', value:'user_id' },
{
label: 'Un surnom.', value: 'nickname'},
{
label: 'Numéro de téléphone portable', value:'phone' },
{
label: 'Solde', value: 'balance'},
{
label: 'Frais de service de la plateforme', value:'service_charge'},
{
label: 'Sexe', value: 'sex' },
{
label: 'Jours de connexion consécutifs', value:'login_day' },
{
label: ' Nombre maximal de jours consécutifs de débarquement ', value: 'login_bigday'},
{
label: 'Heure de connexion', value:'login_time' },
{
label: 'Temps d'ajout', value: 'join_time'},
{
label: 'Statut', value:'status'},
];
const TableTreeChange = () => {
//Prenez levalue Configuré pour répondre à la mise à jour de l'interface
const [selectColum,setSelectColum]=useState(columns)
// Original par défaut sélectionné valueValeur
const [checkedList, setCheckedList] = useState(['user_id']);
// Mettez les sélections multiples que vous avez cochées dans un tableau
const onChange = (list) => {
setCheckedList(list)
};
useEffect(() => {
console.log(checkedList,66666666666666666)
//Utilisation de la doublefor Boucle à sélectionner value Et dans les colonnes du tableau keyLes valeurs sont liées
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]);
}
}
}
// La section suivante du Code est destinée à ajouter une colonne d'action fixe au tableau , Si vous n'avez pas besoin d'ignorer
newList.push({
title: 'Fonctionnement',
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;
边栏推荐
猜你喜欢
【MySQL】数据库视图的介绍、作用、创建、查看、删除和修改(附练习题)
【GF(q)+LDPC】基于二值图GF(q)域的规则LDPC编译码设计与matlab仿真
27-31. Dependency transitivity, principle
C # symmetric encryption (AES encryption) ciphertext results generated each time, different ideas, code sharing
2022 Xinjiang's latest eight members (Safety Officer) simulated examination questions and answers
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?
Mysql 45讲学习笔记(七)行锁
校园网络问题
Uniapp custom environment variables
The solution of win11 taskbar right click without Task Manager - add win11 taskbar right click function
随机推荐
运算符<< >>傻瓜式测试用例
Tar source code analysis 8
7. Agency mode
Another company raised the price of SAIC Roewe new energy products from March 1
tars源码分析之8
Can the out of sequence message complete TCP three handshakes
P26-P34 third_ template
Tree DP
【网络数据传输】基于FPGA的百兆网/兆网千UDP数据包收发系统开发,PC到FPGA
Analysis of tars source code 1
[problem record] 03 connect to MySQL database prompt: 1040 too many connections
校园网络问题
Fundamentals of SQL database operation
Summary of leetcode BFS question brushing
Mysql 45讲学习笔记(十一)字符串字段怎么加索引
The solution of win11 taskbar right click without Task Manager - add win11 taskbar right click function
ADC voltage calculation of STM32 single chip microcomputer
树形dp
Overview of convolutional neural network structure optimization
Data analysis notes 09