react-data-grid
react-data-grid copied to clipboard
Updating selectedRows property on onRowClick event stops double click from working
I have a data grid setup like following:
<DataGrid
rowKeyGetter={rowKeyGetter}
columns={columns}
rows={rows}
onRowsChange={setRows}
selectedRows={selectedRows}
onSelectedRowsChange={setSelectedRows}
rowRenderer={RowRenderer}
onSelectedCellChange={selectedCellChange}
onRowClick={rowClickHandler}
rowHeight={30}
></DataGrid>
I want to set selected rows on row click and not on checkbox click:
const [selectedRows, setSelectedRows] = useState<Set<number>>(() => new Set());
function rowClickHandler(row: any) {
let selectedRowsSet = new Set(selectedRows);
if (selectedRowsSet.has(row.id)) {
selectedRowsSet.delete(row.id);
} else {
selectedRowsSet.add(row.id);
}
setSelectedRows(selectedRowsSet);
}
But the above function disables functionality for double click to edit cell. I think it may be due to the state change that occurs when I call the setSelectedRows
function to update selected row.
Is there any way in which I can click rows for selection and double click for cell edit to work ?
I have the same requirement i want to stop propagating row click on click of checkbox. Also i would like to see the checkbox selected values.
i have the same problem.
onRowClick and on RowDoubleClick are not working together.
@neetinnagap can you create a codesandbox example?
It was my workaround to handle Double click. Look at Screenshot
A Timer and Trigger Double click manually
It would be nicer If the grid can handle it . .
@amanmahajan7
it would be nicer and also important to have an event for onCellNavigate or something like that.
Background: You always need the currently active cell - either I activate it with a click or with the keyboard - and in this case the onCellNavigate event should be triggered. Independent of onRowClick
OnRowDoubleClick should also work independently of onRowClick too.
Thank you for the great job.
@theone3nu did you find the solution to stop event propagation when you select checkbox?
Maybe related to this Issue:
I had some problems with onSelectedCellChange wich causes the cell editor to go out of edit mode. Finnally I found out, that its triggered by the rerender because I stored the position inside the state object. When using onSelectedCellChange{(e)=>{this.selectedCell = e}}
instead of setState it works fine for me.