简体   繁体   English

如何在反应数据网格中的行选择中禁用一行的复选框

[英]How to disable checkbox for a row in rowselection in react-data-grid

 <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
        }
    }}
/>

Above is my code of react-data-grid.以上是我的 react-data-grid 代码。 I want to disable row selection for particular row on some condition or want to disable checkbox for that specific row.我想在某些条件下禁用特定行的行选择,或者想禁用该特定行的复选框。

Please let me know how it can be achieved.请让我知道如何实现。 Thanks谢谢

You can disable the selection of the row by doing the following:-您可以通过执行以下操作来禁用该行的选择:-

onVersionRowsSelect(rows) {
    rows = rows.filter(item => !item.row.isSnapshotQuarantined)
    this.setState({
        selectedIndexes: this.state.selectedIndexes.concat(rows.map(r => r.rowIdx))
    });
}

I am not sure if you can change the visual effect of disabling the checkbox as the checkbox html's control is not exposed by react-data-grid (as per my knowledge).我不确定您是否可以更改禁用复选框的视觉效果,因为react-data-grid未公开复选框 html 的控件(据我所知)。

Hope this helps.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM