簡體   English   中英

我們可以在react-data-grid中創建一些不可編輯的行嗎?

[英]Can we make some rows non-editable in 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}/>

ReactDataGrid將“editable”作為輸入函數。

在這里,我們可以傳遞自定義邏輯來確定是否允許特定單元格進行編輯。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM