[英]How to hide a certain column of a table using antd?
下面的示例代碼
{
title: 'Site',
dataIndex: 'site'
}
我想隱藏站點欄,我還是 antd react ui 的新手。 並且在antd docs的列API中沒有顯示/隱藏功能。 我想在滿足特定條件后隱藏它,例如有 2 種用戶類型。 管理員用戶和一般用戶。
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}
}
}
在您的表組件中調用該函數。(假設您的狀態具有用戶角色)
<Table columns = {this.getColumns(this.state.userRole)} />
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.