-
-
Notifications
You must be signed in to change notification settings - Fork 51
-
I'm using useRowSelect
on a Table to toggle row selection, which works fine. Now I'd like to add a button to reset the selection, i.e. unselect the row. It's purely a visual thing. Is there a way to do this? Like if my select looks like:
const myselect = useRowSelect( data, { onChange: onSelectChange, } );
I was hoping setting myselect.state.id
to null
would work.
Beta Was this translation helpful? Give feedback.
All reactions
You have programmatically access to all functions of the feature. Here is a button which deselects all rows:
const myselect = useRowSelect(
data,
{
onChange: onSelectChange,
}
);
return (
<>
<button onClick={() => myselect.fns.onRemoveAll()}>Reset</button>
<Table ... >...</Table>
</>
);
Let me know if this helps!
Replies: 1 comment 1 reply
-
You have programmatically access to all functions of the feature. Here is a button which deselects all rows:
const myselect = useRowSelect(
data,
{
onChange: onSelectChange,
}
);
return (
<>
<button onClick={() => myselect.fns.onRemoveAll()}>Reset</button>
<Table ... >...</Table>
</>
);
Let me know if this helps!
Beta Was this translation helpful? Give feedback.
All reactions
-
works like a charm, thanks!
Beta Was this translation helpful? Give feedback.