event.dataItem is null during the onSelectionChange event of the Grid.
event.dataItem is null during the onSelectionChange event of the Grid.
https://www.telerik.com/kendo-react-ui/components/grid/api/GridSelectionChangeEvent/#toc-dataitem
https://stackblitz.com/edit/react-xrbucq-6xyhhx?file=app%2Fmain.jsx
any update on it?
As a temporary workaround, the old and the new selected states can be compared:
const onSelectionChange = (event) => {
const newSelectedState = getSelectedState({
event,
selectedState: selectedState,
dataItemKey: DATA_ITEM_KEY,
});
for (const key of Object.keys(newSelectedState)) {
if (!selectedState[key] && newSelectedState[key]) {
let newItem = event.dataItems.find((i) => i[DATA_ITEM_KEY] == key);
console.log(newItem);
}
}
setSelectedState(newSelectedState);
};
https://stackblitz.com/edit/react-pnvg8k-pdq3pc?file=app%2Fmain.jsx
The issue is addressed in the latest dev version and will be available in the next official version of KendoReact. Currently dataItem is available when the checkbox selection column is used. In order to have similar information for the other types of selection we provided startDataItem and endDataItem props that will provide the first and the last selected item.