Initial focus location
The focused location isn't set up by default. You can enable it by setting the initialFocusLocation
property in the ReactGrid
component.
Example:
<ReactGrid
cells={cells}
rows={rows}
columns={columns}
initialFocusLocation={{ rowIndex: 2, colIndex: 1 }}
/>
Note: The focused cell is entirely controlled by the browser's focus mechanism, which means it can easily be set programmatically. The recommended approach for doing this is by using the setFocusedCell
method from the useReactGridAPI hook.
Alternatively, you can directly invoke the .focus()
method. Example:
document.querySelector("rgHiddenFocusTarget rgFocusRowIdx-3 rgFocusColIdx-3").focus();