Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

234
Views
Material-UI X: Could not find the data grid context

I'm using Data Grid Pro component from Material-UI in my React app.

I tried to create a custom toolbar for the DataGridPro component using GridToolbarColumnsButton, GridToolbarFilterButton, GridToolbarDensitySelector, and GridToolbarExport components from the same package with the DataGridPro component.

I also could use a single GridToolbar component to replace all of the four components above.

I need to create the custom toolbar component in a separate component file.

I forked the code for custom toolbar example from Material UI here https://codesandbox.io/s/wduvx and edited the code (separate the custom toolbar into a different component file) here https://codesandbox.io/s/data-grid-pro-toolbar-example-j004m

Both of the codes work fine but when I created another example from scratch here https://codesandbox.io/s/data-grid-pro-toolbar-mine-up6ik, the code produced an error. It said that Material-UI X: Could not find the data grid context (as you can see in the codesandbox).

Here are the dependencies (in package.json file):

"@material-ui/core": "^4.12.3",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.60",
"@material-ui/styles": "^4.11.4",
"@mui/x-data-grid": "^4.0.0",
"@mui/x-data-grid-pro": "^4.0.0",

What's the problem and what's the solution for this case?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You import from the wrong module, because you're using DataGridPro from @mui/x-data-grid-pro:

import { DataGridPro } from "@mui/x-data-grid-pro";

But you import the grid components in @mui/x-data-grid:

import {
  GridToolbarColumnsButton,
  GridToolbarFilterButton,
  GridToolbarDensitySelector,
  GridToolbarExport
} from "@mui/x-data-grid";

Which should have been:

import {
  GridToolbarColumnsButton,
  GridToolbarFilterButton,
  GridToolbarDensitySelector,
  GridToolbarExport
} from "@mui/x-data-grid-pro";
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!