反应表从按钮单击中隐藏各种列
我有一个反应表,其中一个主要的标头,其中包含其下面的多个次级截图。当单击主标头时,我希望隐藏或显示带有名称“存款”的一个辅助标头或显示(切换)。请参阅屏幕截图。
我使用column.toggleheader(column.isvisible)
的解决方案。我俩都想证明这一点,因为那里没有很多材料来做到这一点。我想知道是否使用.getToggleHiddenProps
有整洁的解决方案。老实说,我不明白intererminatecheckbox
例如。 https://github.com/tanstack/tanstack/table/table/discussions/1989 将与特定的列标题值一起使用。
我的答案下面。
I have a react-table with a primary header containing multiple secondary headers underneath it. When the primary header is clicked I want all but one secondary header with name 'deposit' to be hidden, or shown (toggle). See screenshot.
I have a solution using column.toggleHeader(column.isVisible)
. I both wanted to demonstrate this as there wasn't a lot of material out there for how to do this; and I'm wondering if there are neater solutions using .getToggleHiddenProps
. To be honest I don't understand what is going on with IndeterminateCheckbox
eg. https://github.com/TanStack/table/discussions/1989 and how that would be used with specific column header values.
My answer below.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是一些背景 - 这是一个Web3应用程序,它正在获取有关加密钱包的信息 - 因此,为什么代码寻找'0x'并将列标题值降低到
const headerShortended = header.substr.substr(0,5) +'。 。
完成了此初始版本,所以不要对我进行任何粗糙的边缘。虽然很高兴收到建设性的反馈。
Just some background - this is a Web3 app that is getting information about Crypto wallets - hence why the code looks for '0x' and reduces the column header value to
const headerShortened = header.substr(0,5) + '...' + header.substr(header.length - 4,header.length)
(So0x123abcFED1239876
becomesox123...9876
)I've just finished this initial version so don't AT me for any rough edges. Though happy to receive constructive feedback.