2
 <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. 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

2
  • @parashm were you able to find a proper method to achieve this ? I have a requirement where I want all the checkboxes disabled according to a condition. Commented Nov 17, 2020 at 8:12
  • @Dante_97 still didn't find the proper way. Commented Nov 17, 2020 at 11:00

1 Answer 1

2

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).

Hope this helps.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, bro... This is a workaround. And not a proper solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.