Reputation: 105
Sample code below
{
title: 'Site',
dataIndex: 'site'
}
I want to hide the site column and im still new to the antd react ui. And theres no show/hide function in column API of antd docs. I want to hide it after a certain condition has been met like there are 2 user types. Admin user and General user.
if(user_role = admin_user){
show column
elseif(user_role = general_user){
hide column
}
Upvotes: 0
Views: 436
Reputation: 534
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)} />
Upvotes: 1