How to Persist selection between pagination in DataList in fluentui/React
<DetailsList
items={items}
compact={true}
columns={columns}
selectionMode={SelectionMode.multiple}
getKey={getKey}
setKey="none"
layoutMode={DetailsListLayoutMode.justified}
isHeaderVisible={true}
onItemInvoked={onItemInvoked}
/>
I have manage the selection between some other re-render events, I think the solution should be compatible.
The basic idea is to store the selected items by myself, and when the selection changes or grid re-render due to data change, set the selection manually.
define the state to cache selected item, and store selected item in change event:
manually set the selected item after any re-render trigger, remember to switch off event to avoid infinite loop:
bind selection to detaillist by pass
selection={selection}