javascript - Can we make some rows non-editable in react-data-grid? - Stack Overflow

I am using react-data-grid for displaying an editable table in a page. I have used editable: true for e

I am using react-data-grid for displaying an editable table in a page. I have used editable: true for enabling editable columns. But i have some rows which are non-editable. How can i control this in row-level?

Please suggest a solution. PFB the initialization of data grid.

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

I am using react-data-grid for displaying an editable table in a page. I have used editable: true for enabling editable columns. But i have some rows which are non-editable. How can i control this in row-level?

Please suggest a solution. PFB the initialization of data grid.

<ReactDataGrid
    enableCellSelect={true}
    columns={this.state.columns}
    rowGetter={rowGetter}
    rowsCount={this.state.rows.length}
    rowHeight={35}
    minHeight={500}
    onGridRowsUpdated={this.handleGridRowsUpdated}/>
Share Improve this question edited Apr 19, 2017 at 8:49 Lini Susan V asked Apr 10, 2017 at 6:41 Lini Susan VLini Susan V 1,1951 gold badge9 silver badges26 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

ReactDataGrid takes "editable" as input function.

Here, we can pass out custom logic to determine if edit is allowed for the specific cell.

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742322229a4422044.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信