使用 antd 隐藏表的列

2024-01-02

我们如何隐藏表中的列以在前端显示,而该列已经存在于使用 ant design 表的数组中?

例如,我的数组对象中有一个名为 ID 的列,但不需要在表视图中显示,它应该保留在 JSON 列表本身中以供参考。

小提琴链接 https://codesandbox.io/s/1oyyx5981j- 在此示例中,我不想显示表中的 ID 列,但我已将 ID 用于某些参考,例如行删除。


我是这样做的。概念是一样的,都是从数组中删除(过滤掉)该列。

向列对象添加“隐藏”属性,然后将其过滤掉。

let columns = [
  {
    title: "Name",
    dataIndex: "name",
    key: "name"
  },
  {
    title: "Age",
    dataIndex: "age",
    key: "age"
  },
  {
    title: "Address",
    dataIndex: "address",
    key: "address"
  },
  {
    title: "Action",
    key: "action",
    dataIndex: "action",
    hidden: true
  }
].filter(item => !item.hidden);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 antd 隐藏表的列 的相关文章

随机推荐