Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow recreating data grid columns from existing data #914

Merged
merged 10 commits into from
Sep 8, 2022
25 changes: 15 additions & 10 deletions packages/toolpad-app/src/toolpad/propertyControls/GridColumns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
MenuItem,
Stack,
TextField,
Tooltip,
} from '@mui/material';
import { GridColumns, GridColDef, GridAlignment } from '@mui/x-data-grid-pro';
import * as React from 'react';
Expand Down Expand Up @@ -188,16 +189,20 @@ function GridColumnsPropEditor({
<React.Fragment>
<DialogTitle>Edit columns</DialogTitle>
<DialogContent>
<IconButton
aria-label="Recreate columns"
onClick={handleRecreateColumns}
disabled={!hasColumnSuggestions}
>
<RefreshIcon />
</IconButton>
<IconButton aria-label="Add column" onClick={handleMenuClick} disabled={disabled}>
<AddIcon />
</IconButton>
<Tooltip title="Recreate columns">
<IconButton
aria-label="Recreate columns"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool i didn't know, i've removed the unnecessary props + added a span so that the tooltip shows when the "recreate columns" button is disabled (as recommended by the MUI console warnings)

onClick={handleRecreateColumns}
disabled={!hasColumnSuggestions}
>
<RefreshIcon />
</IconButton>
</Tooltip>
<Tooltip title="Add column">
<IconButton aria-label="Add column" onClick={handleMenuClick} disabled={disabled}>
<AddIcon />
</IconButton>
</Tooltip>
<Menu
id="new-column-menu"
anchorEl={menuAnchorEl}
Expand Down