Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

383
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda