I am trying to store unselected items from checkbox selection table. currently selection and deselection is working as expected even when navigating other pages with pagination but I need to get deselected items from the checkbox selection table.
This is my header checkbox selection handler fun
const selectAll = (e) => {
if (e.target.checked) {
const dataIds = data.map((a) => a.id);
const filteredIds = dataIds.filter((id) => !allCheckedItems.includes(id));
const checkedItemsCopy = [...allCheckedItems].concat(filteredIds);
setAllCheckedItems([...checkedItemsCopy]);
setIsSelectedAll((prev) => {
return { ...prev, [pagination.page]: 1 };
});
} else {
const dataId = data.map((a) => a.id);
const checkedItemsCopy = [...allCheckedItems].filter(
(prevSelected) => !dataId.includes(prevSelected),
);
setAllCheckedItems([...checkedItemsCopy]);
setIsSelectedAll((prev) => {
return { ...prev, [pagination.page]: 0 };
}); }}
I have a requirement if user deselected items from the page those unselected items I need to save in my deleteitem array. can some on tell. How Can I store deselected items.
Aucun commentaire:
Enregistrer un commentaire