Skip to main content

readonly

Description​

Optional. Enables/disables the read-only mode

Usage​

readonly?: boolean;

Default config​

readonly: false

Example​

const spreadsheet = new dhx.Spreadsheet("spreadsheet_container", {
readonly: true,
// other config parameters
});

Details​

In the read-only mode, the toolbar, the menu and the formula bar are hidden, and the context menu and the column menu icon are not available. The sheet tabs stay, but without the button that adds a sheet, the sheet context menu and renaming by a double-click.

Users can still read and copy the data:

  • the A1 cell is active after the data is loaded
  • the cells can be navigated with the keyboard and selected with the mouse, and the selection events fire on these actions
  • the cells can be copied with Ctrl (Cmd) + C and searched with Ctrl (Cmd) + F
  • the sheets can be switched in the sheet tabs and with the keyboard
  • the links in cells can be opened, but the buttons that edit and remove a link are disabled in the link popup

Changes of the data are refused:

  • typing, the editing keys, cut and paste, undo and redo, and the shortcuts that format cells, insert a link, add a sheet or show hidden rows and columns are ignored, and screen readers announce "The sheet is read-only"
  • the methods that edit the data, for example, setValue(), setStyle() and deleteRow(), and the startEdit() method are ignored. The parse() and load() methods still load data
  • the fill handle is hidden
  • the columns and rows can't be resized by dragging their borders, and a double-click on a column border doesn't fit the column width to the data

To turn off the keyboard navigation and the selection as well, set the selection option to false. In this case, the Spreadsheet has no active cell, and the cells can't be selected by the mouse, the keyboard or the API:

const spreadsheet = new dhx.Spreadsheet("spreadsheet_container", {
readonly: true,
selection: false,
// other config parameters
});

Change log: The keyboard navigation, the selection, copying and search in the read-only mode were added in v6.0.4

Related articles:

Related sample: Spreadsheet. Readonly