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.
Add a property "hidden" to the column object, then filter it out. Save this answer.
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.
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.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With