Open SusiKette opened 1 year ago
hey @SusiKette
To change the focused cell you can use apiRef.current.setCellFocus(rowId,columnFiled)
.
I think your code can be simplified if you use selectors that come with the packages. for example
const columnFields = gridVisibleColumnFieldsSelector(apiRef).filter((field) =>
apiRef.current.isCellEditable(apiRef.current.getCellParams(params.id, field)),
);
This will give you all visible columns that are editable you do not have to loop to find visible columns. you can refer how its has been implemented for Tab
key below.
Could you give more details of what you're trying to implement? I didn't understand. To move the focus to a specific cell you can use apiRef.current.setCellFocus(id, field)
, but the editing API has some attributes that also allow to control focus. For instance, when changing the mode back to view
, you can also configure where the focus goes with cellToFocusAfter
.
I'm trying to use apiRef
, but I get a Cannot read properties of undefined (reading 'current')
whenever I try to use apiRef
. I think I had this same issue before, which is probably why I started avoiding using `apiRef.
Currently I'm setting the apiRef
like this const apiRef = useGridApiRef();
.
I also tried const apiRef = useGridApiContext();
, but that gives a Could not find the data grid context. It looks like you rendered your component outside of a DataGrid, DataGridPro or DataGridPremium parent component.
error.
have you assigned the apiRef
to the grid?
const apiRef = useGridApiRef();
return <DataGrid ref={apiRef} />
Duplicates
Latest version
Summary š”
Not sure where else to ask this.
I know that this can already be done with tab key, but I was asked to make it so that enter would do that too, and the save the row if on the last cell of the row.
Here is the code I currently run when handling cell key down events:
Everything else works fine, but the focused cell doesn't change. Logging the cell the focus should go to gives the correct cell name, but the focus isn't changing.
Examples š
No response
Motivation š¦
No response
Order ID š³ (optional)
No response