-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
column type "detailPanelToggle" not supported #4769
Comments
Hey @linojon |
Ah right, I didn't notice it. import * as React from "react";
import { DataGrid, GRID_CHECKBOX_SELECTION_COL_DEF } from "@mui/x-data-grid";
import { useDemoData } from "@mui/x-data-grid-generator";
export default function CheckboxSelectionGrid() {
const { data } = useDemoData({
dataSet: "Commodity",
rowLength: 10,
maxColumns: 5
});
const columns = [
{
...GRID_CHECKBOX_SELECTION_COL_DEF,
width: 100
},
...data.columns
];
return (
<div style={{ width: "100%", height: 400 }}>
<DataGrid checkboxSelection {...data} columns={columns} />
</div>
);
} The reason is that those columns are not included in mui-x/packages/grid/x-data-grid/src/colDef/gridDefaultColumnTypes.ts Lines 10 to 20 in bc67359
And I'm not sure we can (or should) include detailPanelToggle there.@m4theushw what do you think? |
@cherniavskii I think we should include them in |
These column types are defined in pro and premium packages and
|
@flaviendelangle yeah, that's the only way we can support pro and premium column types there |
By the way, we have a slightly related topic with the default column type properties of pro / premium features. |
I was leaning into the least effort approach. Adding the pre-processor might be overkill to only make the warning work properly. There's a suggestion to remove the |
100% in favor of that one 😆 |
I'm adding @linojon As a workaround, to avoid console warning you can use the following: <DataGridPro
columnTypes={{
[GRID_DETAIL_PANEL_TOGGLE_COL_DEF.type]: GRID_DETAIL_PANEL_TOGGLE_COL_DEF
}}
/> Codesandbox: https://codesandbox.io/s/customizedetailpaneltoggle-material-demo-forked-vs15s3?file=/demo.tsx |
I'm reopening because in v6 we only plan to remove the |
I think we had an ongoing discussion about
|
We looked into it for a while for Toolpad but in the end didn't use it for the reason that we had something that worked for us already, and it didn't look like it was going to stay a feature. It also didn't seem quite as powerful as we'd need it to be over time. So no blockers from our side for removing |
This comment was marked as duplicate.
This comment was marked as duplicate.
Hi, When using columnTypes={{
[GRID_DETAIL_PANEL_TOGGLE_COL_DEF.type]:
GRID_DETAIL_PANEL_TOGGLE_COL_DEF,
}} I get: So instead of //@ts-ignore on this line I added as string to make TS happy <DataGridPro
columnTypes={{
[GRID_DETAIL_PANEL_TOGGLE_COL_DEF.type as string]:
GRID_DETAIL_PANEL_TOGGLE_COL_DEF,
}}
.... Looks like type is string | undefined Cheers, |
adding the columnTypes prop: |
We can remove the warning to reduce the confusion |
I think that we should stay attentive in cases where developers have typos in their If we assume that TypeScript is meant to give coverage, then indeed, the warning has the potential to be useless. However, TypeScript doesn't fail today: https://codesandbox.io/s/happy-wood-mp3mt6?file=/demo.tsx I imagine because of the permissive type ( mui-x/packages/grid/x-data-grid/src/models/colDef/gridColType.ts Lines 1 to 13 in 6894da1
Should we narrow it down? |
Yes, this is exactly the reason.
I think we can change this in v7. The challenge here is that we use custom column types internally for column identification, like here: mui-x/packages/grid/x-data-grid/src/hooks/features/keyboardNavigation/useGridKeyboardNavigation.ts Line 633 in 62725ed
I imagine we could use Maybe Instead of accepting any export interface GridColTypeOverrides {}
export type GridColType = GridNativeColTypes | keyof GridColTypeOverrides;
declare module '@mui/x-data-grid' {
export interface GridColTypeOverrides {
customType: string;
}
} |
Extracted to #9735 |
Hey @cherniavskii, thanks for posting that example Codesandbox. That was just what I needed to get going! |
Duplicates
Latest version
Current behavior 😯
Receiving warning message in console when adding a detail panel column to columns. Message attached in screen capture. Here's the column definition
Expected behavior 🤔
No response
Steps to reproduce 🕹
Steps:
Context 🔦
Your environment 🌎
`npx @mui/envinfo`
Order ID 💳 (optional)
41465
The text was updated successfully, but these errors were encountered: