Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. var RowRenderer = React.createClass({
  2. setScrollLeft: function(scrollBy) {
  3. //if you want freeze columns to work, you need to make sure you implement this as apass through
  4. this.refs.row.setScrollLeft(scrollBy);
  5. },
  6. getRowStyle: function() {
  7. return {
  8. color: this.getRowBackground()
  9. }
  10. },
  11. getRowBackground: function() {
  12. return this.props.idx % 2 ? 'green' : 'blue'
  13. },
  14. render: function() {
  15. //here we are just changing the style
  16. //but we could replace this with anything we liked, cards, images, etc
  17. //usually though it will just be a matter of wrapping a div, and then calling back through to the grid
  18. return (<div style={this.getRowStyle()}><ReactDataGrid.Row ref="row" {...this.props}/></div>)
  19. }
  20. });
  21.  
  22. var Example = React.createClass({
  23. render: function() {
  24. return (<ReactDataGrid
  25. columns={columns}
  26. rowGetter={rowGetter}
  27. rowsCount={_rows.length}
  28. minHeight={500}
  29. rowRenderer={RowRenderer}/>);
  30. }
  31. });
  32. ReactDOM.render(<Example />, mountNode);
  33.  
  34. const mapStateToProps = (state) => ({
  35. foo: 'bar'
  36. });
  37.  
  38. RowRenderer = connect(mapStateToProps)(RowRenderer);
  39.  
  40. var columns = [
  41. {
  42. key: 'id',
  43. name: 'ID',
  44. locked : true
  45. },
  46. ...
  47. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement