Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

267
Vistas
Clicking component inside renderHeader prop for MUI Data Grid Pro changes the sortModel

I'm using Material UI DataGridPro component to build a React Js app.

I want to create a custom filtering.

The red box in the image below is an IconButton for the filtering view and the blue box is for the column showing/hiding view.

enter image description here

I want to change the behavior of the custom filtering view.

If the filter icon is clicked, then the DataGridPro header will show some Select and TextField components as the filter fields like this image below.

enter image description here

If we click one of the Select and TextField components, the Data Grid Pro component will trigger the onSortModelChange prop to change the sortModel value like this image below.

enter image description here

So now the Data Grid Pro component is sorted based on the column.

Here is the conditions I want: if we click one of the Select and TextField components inside the Data Grid Pro header, the Data Grid Pro will not trigger the onSortModelChange prop which means that the sortModel value is not changed

Here is the playground: https://codesandbox.io/s/stackoverflow-mui-data-grid-render-header-xmwf0?file=/src/App.js

I have tried to add sortable: false for every column but it will not show the arrow icon inside the Data Grid Pro header and prevent the column to be sorted. That's not what I want.

I also have added sortModel and onSortModelChange props for the Data Grid Pro component to control the sortModel value but it hasn't worked.

So, what's the solution for this case?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The MUI X team told me from the Github issue here https://github.com/mui/mui-x/issues/3655#issuecomment-1015263995 that the solution is very simple.

Just add event.stopPropagation() for the onClick prop of each TextField and Select component.

onClick={(event) => event.stopPropagation()}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda