Created
May 25, 2023 16:55
-
-
Save minaairsupport/2f89a4de0788d5994f31385d0de62d47 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
useEffect(() => { | |
const gridApi = gridRef?.current?.api; | |
const handleFirstDataRendered = () => { | |
if (selectedIds && Array.isArray(selectedIds) && selectedIds.length > 0) { | |
selectedIds.forEach((rowId) => { | |
const rowNode = gridRef?.current?.api?.getRowNode(rowId); | |
rowNode?.setSelected(true); | |
setTimeout(() => { | |
rowNode?.setSelected(true); | |
}, 300); | |
}); | |
} | |
}; | |
if (gridApi) { | |
gridApi.addEventListener('firstDataRendered', handleFirstDataRendered); | |
} | |
// Clean up the event listener when the component unmounts | |
return () => { | |
if (gridApi) { | |
gridApi.removeEventListener( | |
'firstDataRendered', | |
handleFirstDataRendered | |
); | |
} | |
}; | |
}, [gridRef]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment