Demo on how to leverage useRowSelection hook
useRowSelection hook
Gives you access to the row selection in the current view.
Note
For getting the selected cells, use the useCellSelection hook.
The return type of this hook is either null
or an array of row info objects, one for each selected row.
Example of how to use useRowSelection
import { useRowSelection } from '@adaptabletools/adaptable-infinite-react';
function YourCmp() {
const rowSelection = useRowSelection();
if (!rowSelection) {
return 'No row selection!';
}
return <Chart options={rowSelection.map(row => ...)} />
}
function App() {
return <Adaptable.Provider {...}>
<YourCmp />
<Adaptable.UI />
<
Note
You can also use the AdaptableState
object (eg via the useAdaptableState hook) to get the selected rows (more specifically, the row ids), but this hooks makes it easier.
This example shows how to leverage useRowSelection
to access the selected rows from the current view.
Select Framework Name
for the X Axis column.
Select github_stars
for the Y Axis column.
If you have row selection, you will see the chart.