5

我正在使用react-data-grid在页面中显示可编辑的表格。我已用于editable: true启用可编辑列。但是我有一些不可编辑的行。我如何在行级控制它?

请提出解决方案。PFB 数据网格的初始化。

<ReactDataGrid
    enableCellSelect={true}
    columns={this.state.columns}
    rowGetter={rowGetter}
    rowsCount={this.state.rows.length}
    rowHeight={35}
    minHeight={500}
    onGridRowsUpdated={this.handleGridRowsUpdated}/>
4

1 回答 1

8

ReactDataGrid 将“可编辑”作为输入函数。

在这里,我们可以传递自定义逻辑来确定是否允许对特定单元格进行编辑。

columns = [
      {
        key: 'id',
        name: 'ID'
      },
      {
        key: 'location_id',
        name: 'Location ID',
        editable: function(rowData) {
          return rowData.allowEdit === true;
        }
      }
]
于 2017-04-11T22:36:46.530 回答