Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we configure the Header of ant design table component?

Tags:

reactjs

antd

We have requirement where we need to show 'Hide/Show' columns feature on the header of table and also we want to provide different color to the header of table in ant design. Can anyone help me how can we do this? I did not find any control to do it as header rendering is completely internal to component.

like image 601
kalpana pagariya Avatar asked Jun 22 '17 02:06

kalpana pagariya


People also ask

How do you make an ant design table responsive?

You can make use of the responsive property on the column that you want to control for screen sizes. 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.

How do you use the sorter on an ANTD table?

Simply define a new sorting routine in utils/sorter. js , add it to the Sorter “enum,” and use it in your sorter prop for any column that needs it.


2 Answers

What I tried to resolve the background colour issue of header is overwrite the ant style class as below

thead[class*="ant-table-thead"] th{
  background-color: yellow !important;
}

I am not sure if this is the correct way of doing or not. antd should provide the property on Table to configure the header style.

Is there any other better way to do it?

like image 145
kalpana pagariya Avatar answered Sep 20 '22 06:09

kalpana pagariya


You can use the <Table.Column title={<...any react node...>}> attribute in combination with ordinary CSS.

like image 42
Jesper We Avatar answered Sep 21 '22 06:09

Jesper We