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

122
Visualizações
Can I store these selected filters in a variable?

Is it possible to store these selected filters in a variable and have it updated as well when the use selects another set of filters? If so, how?

enter image description here

Codesandbox: https://codesandbox.io/s/muidatatables-custom-toolbar-forked-lrbf16

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

To achieve that, you can use onFilterChange callback, like this :

const options = {
...

    onFilterChange: (column, filterList, type) => {
            const selectedFilters = this.extractFilters(filterList);
            console.log(selectedFilters);
          }
}

This function will be called everytime filter list changes.

Then, you declare function extractFilters which will extract all selected filters from passed filterList and it will return array object containting all selected filters :

 extractFilters = (filterList) => {
        let selectedFilters = [];
        filterList.forEach((filter) => {
          if (filter.length > 0) {
            selectedFilters.push(...filter);
          }
        });
        return selectedFilters;
      };

You can store this array in state.

Here is working example.

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