My grid is populated from state after an API call. The piece of state is called data.
const [data, setData] = useState([])
Selection is enabled on the grid, so I can create an array of selected rows with:let allSelected = data.filter((item) => item.selected)
Objects in allSelected have the shape:
[{
_id: 1234
selected: true,
name: "Joe",
},
{
_id: 1235
selected: true,
name: "Jim",
}]
After I perform an operation update on the selected rows, what's the best way to hide those rows?
- Is there a method to get the _IDs of the selected rows?
- Is there a method to hide a given row by _ID?
I'm looking for some way to filter selected rows from data then update state. Something akin to:
const filtered = data.filter((item) => !allSelected.includes(item._id))
setData(filtered)
Thanks!