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

384
Vistas
How to filter rows by default in ag-grid?

I have an ag-grid table that has a column 'status' in which some values are 'active' and some are 'inactive'. I would like my table to only display rows that have an 'active' status by default. Using this question as a reference, I tried to set it like this using onFirstDataRendered:

  const onFirstDataRendered = (params: FirstDataRenderedEvent) => {
    const filter = params.api.getFilterInstance('status');
    if (filter) {
      filter.setModel({
        type: 'equal',
        filter: 'ACTIVE',
      });
      filter.onAnyFilterChanged();
    }
  };

but my code won't compile because it says I can't call onAnyFilterChanged because I "cannot invoke an object which is possibly undefined". Does anyone know how to fix this?

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

0

The issue could be that the type should be equals not equal, as show in the documentation: https://www.ag-grid.com/javascript-data-grid/filter-provided-simple/#simple-filter-options

If that doesn't fix the issue, then try using the Filter API:

  const onFirstDataRendered = (params: FirstDataRenderedEvent) => {
    const filterModel = {
    status: {
        filterType: 'text',
        type: 'equals',
        filter: 'ACTIVE'
        },
    }
    params.api.setFilterModel(filterModel)
    
  };
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