T
TanStack2y ago
stormy-gold

How to track the deselect state

On the documentation when we read we see that the deselection state is stored as false when we deselect a selected row: For reference check image from the documentation . The problem now is in code, there is no false value stored or returned from the state, i can see only the selected rows as
const selectedRows={
id: true
}
const selectedRows={
id: true
}
I think this is a bug or I am doing something wrong. What is the way to use the onRowSelectionChange for getting the deselected state. Worth to note that also the example with code provided in the documentation do not return the deselect state, it is just the true value. Here is what i am doing to track the unselect state (which i think is not right way??):
const onHandleUpdateSelectedRows = (setter: any) => {
const updatedSelectionFromTable = setter(selectedRows) as unknown as RowSelectionState
const updatedObject = Object.assign({}, selectedRows, updatedSelectionFromTable)

Object.keys(selectedRows)
.filter((key) => !updatedSelectionFromTable.hasOwnProperty(key))
.map((key) => (updatedObject[key] = false))

setSelectedRows(updatedObject)
}
const onHandleUpdateSelectedRows = (setter: any) => {
const updatedSelectionFromTable = setter(selectedRows) as unknown as RowSelectionState
const updatedObject = Object.assign({}, selectedRows, updatedSelectionFromTable)

Object.keys(selectedRows)
.filter((key) => !updatedSelectionFromTable.hasOwnProperty(key))
.map((key) => (updatedObject[key] = false))

setSelectedRows(updatedObject)
}
the onHandleUpdateSelectedRows is the onRowSelectionChange. Anyone that can help i really appreciate it. Also If this is a bug i can try to contribute and fix it, just need some guidance.
No description
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?