<ReactDataGrid
columns={[
{ key: 'time', name: 'time', width: 140, formatter: (props) => (<span>{props.value}</span>), sortable: true },
{ key: 'Size', name: 'Size', width: 80, formatter: (props) => (<span>{props.value}</span>) },
{ key: 'qaw', name: 'dash Value', width: 350 },
]}
rowGetter={this.rowGetter}
rowsCount={list.length}
emptyRowsView={() => (<div />)}
rowSelection={{
showCheckbox: true,
onRowsSelected: this.onVersionRowsSelect,
onRowsDeselected: this.onVersionRowsDeselect,
selectBy: {
indexes: this.state.selectedIndexes
}
}}
/>
上面是我的react-data-grid代码。 我想在某些情况下禁用特定行的行选择,或者想要禁用该特定行的复选框。
请告诉我如何实现。 谢谢
最佳答案
您可以通过执行以下操作来禁用行选择:-
onVersionRowsSelect(rows) {
rows = rows.filter(item => !item.row.isSnapshotQuarantined)
this.setState({
selectedIndexes: this.state.selectedIndexes.concat(rows.map(r => r.rowIdx))
});
}
我不确定您是否可以更改禁用复选框的视觉效果,因为 react-data-grid
未公开复选框 html 的控件(据我所知)。
希望这有帮助。
关于javascript - 如何在react-data-grid中的rowselection中禁用行的复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59182913/