Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

436
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!