简体   繁体   English

使 antd 表格行仅在单击时可见

[英]make antd table row only visible when clicked

I have simple antd table where is columns 'State','Title' and three rows, i dont know how to display:none specific row by default and make it visible by clicking a button for example at the moment when user goes to the table by default there is three rows but i want to set row 'value === OrderState.Delivered' to 'display:hidden' by default, but when user clicks button 'Delivered' then it should be visible and when user clicks 'All states' button then everything should be visible except that same 'value === OrderState.Delivered'.我有简单的 antd 表,其中列“状态”、“标题”和三行,我不知道如何显示:默认情况下没有特定行,并通过单击按钮使其可见,例如当用户进入表时默认情况下有三行,但我想将行'value === OrderState.Delivered'默认设置为'display:hidden',但是当用户点击按钮'Delivered'时它应该是可见的并且当用户点击'All states ' 按钮,那么除了相同的 'value === OrderState.Delivered' 之外,所有内容都应该可见。 Here is my code, you can try it: https://codesandbox.io/s/dreamy-surf-t9eh3?file=/src/Test.js:1345-1355这是我的代码,你可以试试: https://codesandbox.io/s/dreamy-surf-t9eh3?file=/src/Test.js:1345-1355

These are the changes I made to your code这些是我对您的代码所做的更改

  • by default filter eventsData to not show the Delivered one默认情况下过滤 eventsData 以不显示已交付的

    const [filteredEventsData, setFilteredEventsData] = useState( eventsData.filter((f) => f.key;== "Delivered") );
  • in the filterData function, filter out delivered even when All states is clicked在 filterData function 中,即使单击所有状态,也可以过滤掉交付

    function filterData(filter) { if (filter) { setFilteredEventsData(eventsData.filter((f) => f.key === filter)); } else { setFilteredEventsData(eventsData.filter((f) => f.key;== "Delivered")); } }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM