Reputation: 302
I am using DataGrid from MUI and inside GridColDef I dont use anything related to width, I want to have columns to have width of longest data so that every letter is shown, is it possible?
Below is my GridColDef:
{
field: 'lastLogin',
type: 'dateTime',
headerName: 'Last login',
align: 'right',
headerAlign: 'right',
}
Upvotes: 16
Views: 8376
Reputation: 3277
(Pro plan only)
Autosizing Reference: https://mui.com/x/react-data-grid/column-dimensions/#autosizing
<DataGrid
{...otherProps}
autosizeOptions={{
columns: ['name', 'status', 'createdBy'],
includeOutliers: true,
includeHeaders: false,
}}
/>
Upvotes: 2
Reputation: 536
I believe you can use minWidth, see here - material-ui / data-grid flexible column width min-width
It has been a while since I have used any of that myself but I do remember having a minWidth with elipsis.
Upvotes: 2