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.

4

2 回答 2

1

解决这个问题的 Griddle v1 方法是定义 aRowEnhancer来提供一个onClick,就像这个例子

  <Griddle
    components={{
      RowEnhancer: OriginalComponent =>
        props => (
          <OriginalComponent
            {...props}
            onClick={() => console.log(`Click Row ${props.griddleKey}`)}
            />
        ),
    }}
    ...
    />
于 2017-11-14T07:46:05.757 回答
0

v1 没有 onRowClick(从 v1.3.1 开始仍然没有)。如果要添加操作,则需要构建自定义行组件或单元格。

于 2017-07-20T02:53:32.417 回答