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

[DataGridPro] Cannot use component from @mui/x-data-grid in a @mui/x-data-grid-pro #2245

Closed
2 tasks done
tjgibbs92 opened this issue Jul 30, 2021 · 4 comments · Fixed by #3688
Closed
2 tasks done
Assignees
Labels
new feature New feature or request plan: Pro Impact at least one Pro user

Comments

@tjgibbs92
Copy link

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

I'm trying to mix the Quick Filter Example with XGrid Multiple column filtering for some of our more needy end users. So I figured that just adding the QuickSearchToolbar from the Quick Filter Example would transfer seamlessly. But XGrid is throwing the error

Material-UI X: Could not find the data grid context.
It looks like you rendered your component outside of a DataGrid or XGrid parent component.

Expected Behavior 🤔

The Quick Filter Example should show with XGrid.

Steps to Reproduce 🕹

https://codesandbox.io/s/material-demo-forked-w2316?file=/demo.js

Above is the broken link but it works perfectly if you change XGrid to DataGrid at line 111.

Context 🔦

I'm attempting to give a user multiple avenues of filtering. They could filter globally or filter by the column.

Your Environment 🌎

`npx @material-ui/envinfo`
System:
    OS: Windows 10 10.0.19043
  Binaries:
    Node: 14.17.3 - C:\Program Files\nodejs\node.EXE
    Yarn: Not Found
    npm: 6.14.13 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: Not Found
    Edge: Spartan (44.19041.1023.0), Chromium (92.0.902.62)   
  npmPackages:
    @material-ui/core: ^4.12.1 => 4.12.1 
    @material-ui/data-grid: ^4.0.0-alpha.34 => 4.0.0-alpha.34 
    @material-ui/icons: ^4.11.2 => 4.11.2 
    @material-ui/lab: ^4.0.0-alpha.60 => 4.0.0-alpha.60
    @material-ui/styles:  4.11.4
    @material-ui/system: ^4.11.3 => 4.12.1
    @material-ui/types:  5.1.0
    @material-ui/utils:  4.11.2
    @material-ui/x-grid: ^4.0.0-alpha.34 => 4.0.0-alpha.34
    @material-ui/x-license:  4.0.0-alpha.34
    @types/react:  17.0.14
    react: ^17.0.2 => 17.0.2
    react-dom: ^17.0.1 => 17.0.2

Order id 💳

#27386

@tjgibbs92 tjgibbs92 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jul 30, 2021
@cbussick
Copy link
Contributor

You are importing components from @material-ui/data-grid (line 5):

import {
  DataGrid,
  escapeRegExp,
  GridToolbarDensitySelector,
  GridToolbarFilterButton
} from "@material-ui/data-grid";

and then use these in the <XGrid> component.

You can change the import to come from @material-ui/x-grid, which fixes the error:

import {
  DataGrid,
  escapeRegExp,
  GridToolbarDensitySelector,
  GridToolbarFilterButton
} from "@material-ui/x-grid";

To have the context it seems necessary to only use components from the same package.

I did the same thing and ended up with the same error a few days ago 😁

@oliviertassinari
Copy link
Member

Interesting, this issue makes the case for #924 (comment)

@flaviendelangle

This comment has been minimized.

@flaviendelangle flaviendelangle added component: data grid This is the name of the generic UI component, not the React module! new feature New feature or request and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 2, 2021
@flaviendelangle flaviendelangle changed the title XGrid: Could not find the data grid context. [XGrid] Cannot use component from @material-ui/data-grid in a XGrid Aug 2, 2021
@oliviertassinari

This comment has been minimized.

@oliviertassinari oliviertassinari added the ready to take Help wanted. Guidance available. There is a high chance the change will be accepted label Aug 6, 2021
@oliviertassinari oliviertassinari removed the ready to take Help wanted. Guidance available. There is a high chance the change will be accepted label Aug 9, 2021
@oliviertassinari oliviertassinari changed the title [XGrid] Cannot use component from @material-ui/data-grid in a XGrid [DataGridPro] Cannot use component from @mui/x-data-grid in a @mui/x-data-grid-pro Nov 12, 2021
@oliviertassinari oliviertassinari added components: DataGridPro and removed component: data grid This is the name of the generic UI component, not the React module! labels Nov 12, 2021
@oliviertassinari oliviertassinari added the plan: Pro Impact at least one Pro user label Dec 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or request plan: Pro Impact at least one Pro user
Projects
None yet
5 participants