Reputation: 295
I am using a DataGrid to manage a service configuration. I would like to use the auto-generated row checkboxes to manage multiple delete operations, but would like to use the onRowClick event to feed row data to a modal dialog form for editing. My onRowClick handler works just fine and populates the modal exactly the way I want it to. Unfortunately, clicking on the row also selects the row -- in other words, the checkbox for the row clicked is selected. I would like the row to be selected only when the checkbox itself is clicked, not when the row is clicked.
My DataGrid declaration looks like this.
<DataGrid
columns={this.columns}
rows={fmConfigs}
pageSize={10}
checkboxSelection
autoHeight
onRowClick={(rowData) => this.handleClickOpenFmConfigForm(rowData.row)}
/>
Normally, I would expect there be a second argument to the onRowClick handler to represent the event, so I could call something like e.stopPropagation(), but the only thing passed is an object of type GridRowParams, for which there is no documentation. I was hoping that maybe the event object was buried in there somewhere but I can't find it. When I print the object to the console, I can see that there is a lot of data -- that's how I was able to find the row data I needed to pass to my form -- but I do not see the event.
Does anyone have any idea how this can be done?
Upvotes: 5
Views: 8672
Reputation: 1
but if i tried to use the row id that was checked and it is not work. I want that clicking on a row will open a popup on this row but also want thet user will be able to select a few rows (to download ) i tryed onSelectionModelChange but i did console log
};
but it is not worked
const handleSelectionChange = (selection) => {
console.log('selection changed');
console.log(selection);
// sendSelectedBookIds(selection);
<DataGrid
rows={manuscriptInfoList}
columns={columns}
initialState={{
pagination: {
paginationModel: { page: 0, pageSize: 10 },
},
}}
pageSizeOptions={[10, 25, 50, 100]}
checkboxSelection
disableRowSelectionOnClick
onRowClick={(params, event) => handleRowClick(params, event)}
slots={{
toolbar: CustomToolbar,
noRowsOverlay: CustomNoRowsOverlay,
}}
onSelectionModelChange={handleSelectionChange}
/> ```
Upvotes: 0