【问题标题】:React-virtualized - is it possible to use custom column?React-virtualized - 是否可以使用自定义列?
【发布时间】:2019-07-16 23:57:24
【问题描述】:

我正在使用 react-virtualized 来渲染我的表格。是否可以用自定义组件替换默认的 Column 组件?我不断收到此错误 Failed prop type: Table only accepts children of type Column

【问题讨论】:

    标签: react-virtualized


    【解决方案1】:

    是的,当然,你可以通过使用 Column 中的 cellRenderer 属性来实现,这是一个回调函数,它会给你一堆参数,你需要返回将在单元格中呈现的自定义组件

    <Column key={column.dataKey + column.label + index} dataKey={column.dataKey}
            cellRenderer={
                ({ cellData, rowIndex, dataKey }) => (
                    <CheckBox
                      cellData={cellData}
                      changeCheckBox={changeCheckBoxHandler.bind(
                        this,
                        rowIndex,
                        dataKey
                      )}
                    />
                  )
                }/>
    

    您可以在此处找到详细信息。 https://github.com/bvaughn/react-virtualized/blob/master/docs/Column.md#cellrenderer

    【讨论】:

      【解决方案2】:

      您为什么要这样做?您必须使用Column 组件来定义每一列,然后您可以在每个Column 中呈现您想要的任何内容。

      【讨论】:

        猜你喜欢
        • 2017-12-28
        • 1970-01-01
        • 1970-01-01
        • 2020-03-23
        • 2018-01-30
        • 1970-01-01
        • 2016-11-25
        • 1970-01-01
        • 2016-10-14
        相关资源
        最近更新 更多