5

Was tasked to upgrade from Griddle v0.7 to Griddle v1.1. But I can't seeme to get onRowClick to work.

import React, { Component } from 'react';
import Griddle from 'griddle-react';

export default class Table extends Component {
  render() {
    const data = [...something];

    return <Griddle
      data={data} 
      onRowClick={() => console.log("row clicked")} /> 
  }
}

If I look through the issues on github or other examples, this should work just fine.

  • were you ever able to figure this out? I'm currently experiencing the same issue (upgrading from 0.7 to 1.5), and can't seem to find anyway to get `onClick` to fire. – Erik Jun 13 '17 at 20:59

2 Answers2

1

The Griddle v1 way to solve this would be to define a RowEnhancer to provide an onClick, like this example:

  <Griddle
    components={{
      RowEnhancer: OriginalComponent =>
        props => (
          <OriginalComponent
            {...props}
            onClick={() => console.log(`Click Row ${props.griddleKey}`)}
            />
        ),
    }}
    ...
    />
dahlbyk
  • 75,175
  • 8
  • 100
  • 122
0

There is no onRowClick as v1 (and still none as of v1.3.1). You need to build a custom row component or cell if you want to add an action.

sww314
  • 1,252
  • 13
  • 17