2017-04-10 102 views
1

我正在使用react-data-grid在頁面中顯示可編輯的表格。我使用editable: true來啓用可編輯列。但是我有一些不可編輯的行。我怎樣才能控制這一行級?我們可以使一些行在react-data-grid中不可編輯嗎?

請提出解決方案。 PFB數據網格的初始化。

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

回答

1

ReactDataGrid將「可編輯」作爲輸入函數。

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

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

請讓我知道我們在哪裏可以獲得有關ReactDataGrid的文檔。我只發現[官方網站](http://adazzle.github.io/react-data-grid/documentation.html#/componentsDocs)。但找不到你分享的細節。 –

+0

我在文檔中也找不到這個。我曾經需要類似的方案,然後結束搜索他們的源文件文件(「react-data-grid.js」)以尋求解決方案。 如果你在這個文件中搜索「canEdit:」,你可以在這裏找到關於這個方法的註釋。 –

+0

感謝您的信息:) –

相關問題