gregnb / mui-datatables

Datatables for React using Material-UI
MIT License
2.71k stars 932 forks source link

Fixed Column width if the View column changing #1106

Open yuriy-voypost opened 4 years ago

yuriy-voypost commented 4 years ago

First of all thank you all for this great library. Its just awesome.

Is this possible to have fixed columns width if the View column changing? For now columns get all available width and the data of table a bit jumps. Is there some way to make columns width fixed?

I try to override styles but it not helps.

Expected Behavior

It would be great if we could have fixed column width option

Current Behavior

For now columns get all available width of the table. captured (1)

Your Environment

Tech Version
Material-UI 4.4.3
MUI-datatables 2.12.4
React 16.8.6
browser Chrome
etc
patorjk commented 4 years ago

You may be able to accomplish this with the setCellHeaderProps option (ex: https://github.com/gregnb/mui-datatables/blob/master/examples/customize-styling/index.js). With it you can set the style/className property of the table header cells, so you could potentially set the column width there.

StorkST commented 4 years ago

Hello. Could there be an example on how to set parameters (width, padding...) for a column with setCellHeaderProps ? Example customize-styling doesn't show and this question keeps coming back. And I face the same problem. Thanks for your help.

Tried with:

  setCellHeaderProps: (value) => (
   {
    style: {
       'paddingRight': '0px'
     }
   }
 ),

But padding isn't much affected: