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

386
Vistas
How to filter selected Rows in AG grid and keep it as selected?

I want to filter my AG grid rows based on checkbox selection and I want to keep them as selected.

I know using below method I can filter selected rows but after filtering the rows are losing its selected state.

gridOptions.api.setRowData(gridOptions.api.getSelectedRows())

I can run gridoptions.api.selectAll() but I have to avoid it as I don't want AG grid selection change event to be triggered.

Any Idea how can I achieve it?

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

0

Use ag-grid filter external to filter columns by hand. In the rowdefintion set the filter for the rows to true. Override the methods isExternalFilterPresent and doesExternalFilterPass from ag-grid in HTML

  <ag-grid-angular
  [columnDefs]="columnDefs"
  [isExternalFilterPresent]="isExternalFilterPresent"
  [doesExternalFilterPass]="doesExternalFilterPass"
  [rowData]="rowData"
  (gridReady)="onGridReady($event)"
></ag-grid-angular>

in .ts define outside of your component (or do it static)

// Used in isExternalFilterPresent() to detect if (external)filter is active or not
let Gobal_filterSelectedDocuments: boolean;

and in your component

onToggleDocumentsFilterClick(event: MatSlideToggleChange) {
    Gobal_filterSelectedDocuments = event.checked;
    // nesseary notification to enable the filter
    this.gridApiObjects.onFilterChanged()
}

isExternalFilterPresent() {
    // Here we have no access to the 'this.' of the component. Use a Global Variable instedt.
    return Gobal_filterSelectedDocuments;
}

doesExternalFilterPass(node) {
    // Show only selected nodes
    return node.isSelected();
}

The biggest issue is that the isExternalFilterPresent() has a differnt scope and the this. is an angular object (gridapi?) not the current component. So i needed a gobal/static variable to work around this.

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