I'm trying to implement a custom filter for material table.
The table data is:
[
{
name: "Tomato",
color: "red",
quantity: 12,
id: "01"
},
{
name: "Banana",
color: "yellow",
quantity: 5,
id: "02"
},
{
name: "Lemon",
color: "yellow",
quantity: 20,
id: ""
},
{
name: "Blueberry",
color: "blue",
quantity: 50,
id: ""
}
]
Columns:
[
{
title: "Name",
field: "name",
filterComponent: props => {
return (
<FormControlLabel
control={<Checkbox color="primary" />}
label="Custom filter"
labelPlacement="end"
/>
);
}
},
{ title: "Color", field: "color", filtering: false },
{ title: "Quantity", field: "quantity", filtering: false },
{ title: "Code", field: "code", filtering: false, hidden: true }
]
Link to code sandbox here
The checkbox filter I'm trying to implement has to hide/show all rows that have "id" property of an empty string.