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

440
Visualizações
How to hide rows in material table based on a value in data?

I have an array of data being displayed in a material-table. My data has a field called Active and its value can be either 0 or 1. If the Active value is 0, then that object is inactive. If Active is one, the object is active.

I want the user to have the ability to check a checkbox in the table toolbar and hide all inactive data.

I am using @material-ui/core for my UI components.

If the checkbox is checked/true, then the data where the Active field is 0 are hidden. If the checkbox unchecked/false, then all of the data in the array is displayed.

    const [intakes, setIntakes] = useState([]);

    function IntakeList() {
        const CustomToolbarComponent = (props) => {
            return (
                <div
                    style={{
                        display: "flex",
                        justifyContent: "flex-end",
                        alignItems: "center",
                    }}
                >
                    <FormControlLabel control={<Checkbox />} label="Hide inactive objects" />
                    <div>
                        <MTableToolbar {...props} />
                    </div>
                </div>
            );
        };

        return (
            <MaterialTable
                title=""
                data={intakes.intakes}
                columns={columns}
                components={{
                    Toolbar: (props) => <CustomToolbarComponent {...props} />,
                }}
            />
        );
    }

Here is a short example of my JSON:

{
  "intakes": [
    {
      "ID": 1,
      "Active": 0
    },
    {
      "ID": 2,
      "Active": 1
    }
  ]
}
about 4 years ago · Juan Pablo Isaza
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