I've implemented on a grid from react-virtualized, the possibility for the user to sort values on click of an icon. I wish that the icon have the same behavior than the sort icon on react-bootstrap table.
Currently, my icon is working this. The column number doesn't come back to the circle icon, when I click on the column string.
Here's my sort component :
class SortColumn extends React.Component {
constructor(props) {
super(props);
this.onClick = this.onClick.bind(this);
this.state = {
sortIcon: 'fa fa-circle',
id: null,
};
}
onClick() {
const { columnId, sort } = this.props;
const newSort = sort;
newSort.id = columnId;
if (sort.asc === true) {
newSort.asc = false;
this.setState({
sortIcon: 'fa fa-chevron-down',
id: columnId,
});
} else if (sort.asc === false) {
newSort.asc = true;
this.setState({
sortIcon: 'fa fa-chevron-up',
id: columnId,
});
}
this.props.updateSort(newSort);
}
render() {
return (
<i
onClick={this.onClick}
styleName="columnSettingsSort"
className={this.state.sortIcon} aria-hidden="true"
/>
);
}
}
Do you have any ideas ?