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

175
Vistas
React Ag-Grid external filter output is delayed from input

I am trying to use external filter with ag-grid in react and it does not seem to work properly.

When I select the input on the external filter, nothing in the table gets filtered. On the next selection the table gets filtered according to the previous selection. This continues to happen for all subsequent inputs, basically the table gets filtered for the previously selected input and not the current one

I have used the example from the ag-grid website and modified it to work with useState.

They main functions for the external filter are as follows.

  const isExternalFilterPresent = () => {
    return true;
  };

  const doesExternalFilterPass = (node) => {
    switch (filterVal) {
      case "below25":
        return node.data.age < 25;
      case "between25and50":
        return node.data.age >= 25 && node.data.age <= 50;
      case "above50":
        return node.data.age > 50;
      case "dateAfter2008":
        return asDate(node.data.date) > new Date(2008, 1, 1);
      default:
        return true;
    }
  };

The following useEffect ensures that the filter change is only registered after setState is complete

  useEffect(() => {
    if (!!gridApi) {
      gridApi.onFilterChanged();
    }
  }, [filterVal, gridApi]);

Below is the codesandbox link for the demo and the complete code

https://codesandbox.io/s/ag-grid-external-filter-j6tru

I do not understand why this is happening? Can anyone help with this?

about 4 years ago · Juan Pablo Isaza
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