Skip to content
Snippets Groups Projects
Commit 85acbedc authored by Esko Ikkala's avatar Esko Ikkala
Browse files

Add custom header renderer

parent 9751c728
No related branches found
No related tags found
No related merge requests found
...@@ -18,8 +18,11 @@ import { ...@@ -18,8 +18,11 @@ import {
AutoSizer, AutoSizer,
Column, Column,
Table, Table,
SortIndicator
} from 'react-virtualized'; } from 'react-virtualized';
// https://github.com/bvaughn/react-virtualized/issues/650 // https://github.com/bvaughn/react-virtualized/issues/650
// https://github.com/bvaughn/react-virtualized/blob/master/docs/usingAutoSizer.md
const styles = () => ({ const styles = () => ({
root: { root: {
...@@ -90,9 +93,30 @@ class VirtualizedTable extends React.PureComponent { ...@@ -90,9 +93,30 @@ class VirtualizedTable extends React.PureComponent {
render() { render() {
const { classes, list, analysisView } = this.props; const { classes, list, analysisView } = this.props;
const rowGetter = ({index}) => this._getDatum(list, index); const rowGetter = ({index}) => this._getDatum(list, index);
//https://github.com/bvaughn/react-virtualized/blob/master/docs/usingAutoSizer.md const headerRenderer = ({
dataKey,
label,
sortBy,
sortDirection,
}) => {
const showSortIndicator = sortBy === dataKey;
const children = [
<span
className="ReactVirtualized__Table__headerTruncatedText"
key="label"
title={label}>
{label}
</span>,
];
if (showSortIndicator) {
children.push(
<SortIndicator key="SortIndicator" sortDirection={sortDirection} />,
);
}
return children;
};
// Some extra columns for analysis view
let modifier = ''; let modifier = '';
let base = ''; let base = '';
let collector = ''; let collector = '';
...@@ -132,8 +156,6 @@ class VirtualizedTable extends React.PureComponent { ...@@ -132,8 +156,6 @@ class VirtualizedTable extends React.PureComponent {
); );
} }
const csvLink = <CSVLink data={list.toArray()}>Results as CSV</CSVLink>;
return ( return (
<div className={classes.root}> <div className={classes.root}>
<Grid container className={classes.container}> <Grid container className={classes.container}>
...@@ -200,6 +222,7 @@ class VirtualizedTable extends React.PureComponent { ...@@ -200,6 +222,7 @@ class VirtualizedTable extends React.PureComponent {
label="Name" label="Name"
cellDataGetter={({rowData}) => rowData.label} cellDataGetter={({rowData}) => rowData.label}
dataKey="label" dataKey="label"
headerRenderer={headerRenderer}
width={150} width={150}
/> />
{modifier} {modifier}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment