[英]How to hide a certain column of a table using antd?
Sample code below下面的示例代码
{
title: 'Site',
dataIndex: 'site'
}
I want to hide the site column and im still new to the antd react ui.我想隐藏站点栏,我还是 antd react ui 的新手。 And theres no show/hide function in column API of antd docs.
并且在antd docs的列API中没有显示/隐藏功能。 I want to hide it after a certain condition has been met like there are 2 user types.
我想在满足特定条件后隐藏它,例如有 2 种用户类型。 Admin user and General user.
管理员用户和一般用户。
if(user_role = admin_user){
show column
elseif(user_role = general_user){
hide column
}
getColumns = (userRole) => {
switch(userRole){
case 'AdminUser': { return //return admin user columns here }
case 'GeneralUser': { return //return the genral user columns here }
default: { return //handle other cases.. or raise error}
}
}
In your table component call the function.(Assuming your state has the user role)在您的表组件中调用该函数。(假设您的状态具有用户角色)
<Table columns = {this.getColumns(this.state.userRole)} />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.