Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide column for table using antd

Tags:

antd

How can we hide a column from the table for displaying in frontend which already exists in the array for using ant design table?

For example, I have a column called ID in my array object, but no need to show in the table view, it should be kept in the JSON list itself for some reference purpose.

Fiddle link - In this example I don't want to show the ID column in the table, but I have used the ID for some reference like a row delete.

like image 781
Jaison James Avatar asked Feb 17 '19 11:02

Jaison James


People also ask

How do I hide columns in ANTD table?

Add a property "hidden" to the column object, then filter it out. Save this answer.

How do I hide columns in a table?

To hide a column entirely from view, meaning it will not be displayed in either the normal or details row, simply use the visible column option and set it to false . This example shows a table where the first column ID is completely hidden from view using the data-visible column attribute.

How do you make an ant design table responsive?

Just add a From To column with a custom render function, and set the responsive property on that column to only show on xs screens. The From and To columns will have the responsive property set to show on md and above.


1 Answers

Here is how I did it. The concept is the same, which is to remove (filter out) the column from the array.

Add a property "hidden" to the column object, then filter it out.

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);
like image 90
Sem Avatar answered Sep 28 '22 12:09

Sem