Skip to content

Instantly share code, notes, and snippets.

@jonase
Created August 31, 2016 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonase/451bc04ea1e579bead645b00fc4014cc to your computer and use it in GitHub Desktop.
Save jonase/451bc04ea1e579bead645b00fc4014cc to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import { Grid, ScrollSync, AutoSizer } from 'react-virtualized';
import 'react-virtualized/styles.css';
class App extends Component {
render() {
return (
<div className="App">
<div className='Table' style={{width: 600, height: 400}}>
<AutoSizer>
{({ width, height }) =>
<ScrollSync>
{({ onScroll, scrollLeft }) => (
<div>
<div className='TableHeader'>
<Grid
scrollLeft={scrollLeft}
style={{overflowX: 'hidden'}}
width={width}
height={30}
columnWidth={200}
rowHeight={30}
columnCount={100}
rowCount={1}
cellRenderer={({ columnIndex, isScrolling, rowIndex }) => `H${columnIndex}`}
/>
</div>
<div className='TableData'>
<Grid
onScroll={onScroll}
width={width}
height={height-30}
columnWidth={200}
rowHeight={30}
columnCount={100}
rowCount={100}
cellRenderer={({ columnIndex, isScrolling, rowIndex }) => `C${rowIndex}:${columnIndex}`
/>
</div>
</div>
)}
</ScrollSync>
}
</AutoSizer>
</div>
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment