setFocusedCell()
Description
Sets focus on the specified cell
Usage
setFocusedCell(cell: string, scroll?: boolean): void;
Parameters
cell- (required) the id of a cell to set focus onscroll- (optional) whether to scroll the Spreadsheet to the cell,trueby default
Example
const spreadsheet = new dhx.Spreadsheet("spreadsheet_container", {
// config parameters
});
spreadsheet.parse(data);
spreadsheet.selection.setFocusedCell("D4");
Details
The method makes the specified cell active and, after the redraw, moves the keyboard focus to it. The keyboard focus isn't moved if it is:
- in an element outside the Spreadsheet
- on the toolbar, the menu or the sheet tabs reached with the keyboard
- in an open cell editor
If the keyboard focus is on the page body, for example, right after the page is loaded, the method moves it to the cell.
The same rules apply to any other change of the active cell, for example, by another API method.
If the beforeFocusSet event handler returns false, the active cell isn't changed and the keyboard focus isn't moved.
The method does nothing while the selection is turned off with the selection: false configuration option or the selection.disable() method.
Change log: Moving the keyboard focus to the cell was added in v6.0.4
Related articles: