我们可以在react-data-grid中创建一些不可编辑的行吗?

Lin*_*n V 3 javascript datatable reactjs react-data-grid

我正在使用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}/>
Run Code Online (Sandbox Code Playgroud)

Sud*_*tha 6

ReactDataGrid将"editable"作为输入函数.

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

columns = [
      {
        key: 'id',
        name: 'ID'
      },
      {
        key: 'location_id',
        name: 'Location ID',
        editable: function(rowData) {
          return rowData.allowEdit === true;
        }
      }
]
Run Code Online (Sandbox Code Playgroud)