Sort non-number columns ASCending by default.

- And number columns DESCending by default.
- default: when you sort by that column for the first time.
This commit is contained in:
Simon Howe
2016-08-23 11:23:30 +02:00
parent fd82651f96
commit 66561e1d8e

View File

@@ -163,9 +163,11 @@ export default class NodeDetailsTable extends React.Component {
handleHeaderClick(ev, headerId) {
ev.preventDefault();
const sortedDesc = headerId === this.state.sortBy
? !this.state.sortedDesc : this.state.sortedDesc;
const sortBy = headerId;
const header = this.getColumnHeaders().find(h => h.id === headerId);
const defaultSortDesc = header.dataType === 'number';
const sortedDesc = header.id === this.state.sortBy
? !this.state.sortedDesc : defaultSortDesc;
const sortBy = header.id;
this.setState({sortBy, sortedDesc});
this.props.onSortChange(sortBy, sortedDesc);
}