onSelect and mode: 'radio',
When using the table with mode: 'radio', I only get an onSelect event with isSelected true for the new selection, but there is not event for the "unselected" item. (I would have expected to receive two events, an isSelected=false for the previously selected item, and isSelected=true for the newly selected item.)
This behaviour makes it hard to create generic (for both modes) components on top of the react-bootstrap-table that handle the selection state.
Actually, what I would like to have is an afterSelect event, that is triggered after a selection change is done (not before, like onSelect, which is also useful). Otherwise, one has to manage the selected rows state oneself, which can be difficult when you have a chain of onSelect callbacks.
Or do I miss something?
Thanks, -Stephane
@stephanebarbey : What would you do with the unselected one? You would be more interested on the selected one at any point of time if it is a radio button, right?
I used to do this always:
- Create a state variable
- When selected add that row in the state variable
The state variable will always have one row.
If it is a checkbox, I push or pop from the state variable based on the isSelected.
Ideally speaking, the isSelected for the radio is not at all required in my point of view. What do you say @AllenFang ?
The state variable will always have one row.
If it is a checkbox, I push or pop from the state variable based on the isSelected.
Ideally speaking, the isSelected for the radio is not at all required in my point of view.
@email2vimalraj absolutely right.
you can get the unselect item by current state before you change it when onSelect is done