Disabled cells
Make specified cells read-only to protect them from unwanted changes but still allow navigation and copying of data.
Disable individual cells, entire columns, or entire rows to prevent user edits. Use readOnly on cells, columns, or the whole grid.
Overview
Disabling a cell makes the cell read-only or non-editable. Both have similar outcomes, with the following differences:
Read-only cellreadOnly: true | Non-editable celleditor: false |
|---|---|
Has an additional CSS class (htDimmed) | Has no additional CSS class |
| Copy works, paste doesn’t work | Copy-paste works |
| Drag-to-fill doesn’t work | Drag-to-fill works |
Can’t be changed by populateFromArray() | Can be changed by populateFromArray() |
To disable a cell
To make the entire grid read-only, set readOnly to true as a top-level grid option.
/* file: app.component.ts */import { Component } from '@angular/core';import { GridSettings, HotTableModule } from '@handsontable/angular-wrapper';
@Component({ selector: 'example-readonly-grid', standalone: true, imports: [HotTableModule], template: ` <div> <hot-table [data]="data" [settings]="gridSettings"></hot-table> </div>`,})export class AppComponent { readonly data = [ { car: 'Tesla', year: 2017, chassis: 'black', bumper: 'black' }, { car: 'Nissan', year: 2018, chassis: 'blue', bumper: 'blue' }, { car: 'Chrysler', year: 2019, chassis: 'yellow', bumper: 'black' }, { car: 'Volvo', year: 2020, chassis: 'white', bumper: 'gray' }, ];
readonly gridSettings: GridSettings = { readOnly: true, height: 'auto', colHeaders: ['Car', 'Year', 'Chassis color', 'Bumper color'], autoWrapRow: true, autoWrapCol: true };}/* end-file */
/* file: app.config.ts */import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';import { registerAllModules } from 'handsontable/registry';import { HOT_GLOBAL_CONFIG, HotGlobalConfig, NON_COMMERCIAL_LICENSE } from '@handsontable/angular-wrapper';
// register Handsontable's modulesregisterAllModules();
export const appConfig: ApplicationConfig = { providers: [ provideZoneChangeDetection({ eventCoalescing: true }), { provide: HOT_GLOBAL_CONFIG, useValue: { license: NON_COMMERCIAL_LICENSE } as HotGlobalConfig, }, ],};/* end-file */<div> <example-readonly-grid></example-readonly-grid></div>To disable a column
To make a column read-only, declare it in the columns configuration option. The column remains available for keyboard navigation and copying data (Ctrl/Cmd+C), but editing and pasting are disabled. You can also define a special renderer function that will dim the read-only values, providing a visual cue for the user that the cells are read-only.
/* file: app.component.ts */import { Component } from '@angular/core';import { GridSettings, HotTableModule } from '@handsontable/angular-wrapper';
@Component({ selector: 'example1-disabled-cells', standalone: true, imports: [HotTableModule], template: ` <div> <hot-table [data]="data" [settings]="gridSettings"></hot-table> </div>`,})export class AppComponent {
readonly data = [ { car: 'Tesla', year: 2017, chassis: 'black', bumper: 'black' }, { car: 'Nissan', year: 2018, chassis: 'blue', bumper: 'blue' }, { car: 'Chrysler', year: 2019, chassis: 'yellow', bumper: 'black' }, { car: 'Volvo', year: 2020, chassis: 'white', bumper: 'gray' }, ];
readonly gridSettings: GridSettings = { height: 'auto', colHeaders: ['Car', 'Year', 'Chassis color', 'Bumper color'], autoWrapRow: true, autoWrapCol: true, columns: [ { data: 'car', readOnly: true, }, { data: 'year', }, { data: 'chassis', }, { data: 'bumper', }, ] };}/* end-file */
/* file: app.config.ts */import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';import { registerAllModules } from 'handsontable/registry';import { HOT_GLOBAL_CONFIG, HotGlobalConfig, NON_COMMERCIAL_LICENSE } from '@handsontable/angular-wrapper';
// register Handsontable's modulesregisterAllModules();
export const appConfig: ApplicationConfig = { providers: [ provideZoneChangeDetection({ eventCoalescing: true }), { provide: HOT_GLOBAL_CONFIG, useValue: { license: NON_COMMERCIAL_LICENSE } as HotGlobalConfig, }, ],};/* end-file */<div> <example1-disabled-cells></example1-disabled-cells></div>To disable a row
To make specific cells read-only, use the cells function to set the readOnly property conditionally. The example below makes cells that contain the word “Nissan” read-only.
/* file: app.component.ts */import { AfterViewInit, Component, ViewChild } from '@angular/core';import { GridSettings, HotTableComponent, HotTableModule } from '@handsontable/angular-wrapper';
@Component({ selector: 'example2-disabled-cells', standalone: true, imports: [HotTableModule], template: ` <div> <hot-table [data]="data" [settings]="gridSettings"></hot-table> </div>`,})export class AppComponent implements AfterViewInit { @ViewChild(HotTableComponent, { static: false }) readonly hotTable!: HotTableComponent;
readonly data = [ { car: 'Tesla', year: 2017, chassis: 'black', bumper: 'black' }, { car: 'Nissan', year: 2018, chassis: 'blue', bumper: 'blue' }, { car: 'Chrysler', year: 2019, chassis: 'yellow', bumper: 'black' }, { car: 'Volvo', year: 2020, chassis: 'white', bumper: 'gray' }, ];
readonly gridSettings: GridSettings ={ height: 'auto', colHeaders: ['Car', 'Year', 'Chassis color', 'Bumper color'], autoWrapRow: true, autoWrapCol: true };
ngAfterViewInit(): void { const hot = this.hotTable?.hotInstance;
hot?.updateSettings({ cells: (row: number, col: number, _: any) => { if (hot.getData()[row][col] === 'Nissan') { return { readOnly: true }; }
return {}; }, }); }}/* end-file */
/* file: app.config.ts */import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';import { registerAllModules } from 'handsontable/registry';import { HOT_GLOBAL_CONFIG, HotGlobalConfig, NON_COMMERCIAL_LICENSE } from '@handsontable/angular-wrapper';
// register Handsontable's modulesregisterAllModules();
export const appConfig: ApplicationConfig = { providers: [ provideZoneChangeDetection({ eventCoalescing: true }), { provide: HOT_GLOBAL_CONFIG, useValue: { license: NON_COMMERCIAL_LICENSE } as HotGlobalConfig, }, ],};/* end-file */<div> <example2-disabled-cells></example2-disabled-cells></div>Non-editable cells behave like any other cells apart from preventing you from manually changing their values.
To disable a column (non-editable)
To make a column non-editable, declare it in the columns configuration option. The column’s basic behavior does not change — you can still use keyboard navigation, Ctrl/Cmd+C, Ctrl/Cmd+V, and drag-to-fill. You can also define a special renderer function that will dim the editor value, providing a visual cue that the cell is non-editable.
/* file: app.component.ts */import { Component } from '@angular/core';import { GridSettings, HotTableModule } from '@handsontable/angular-wrapper';
@Component({ selector: 'example3-disabled-cells', standalone: true, imports: [HotTableModule], template: ` <div> <hot-table [data]="data" [settings]="gridSettings"></hot-table> </div>`,})export class AppComponent {
readonly data = [ { car: 'Tesla', year: 2017, chassis: 'black', bumper: 'black' }, { car: 'Nissan', year: 2018, chassis: 'blue', bumper: 'blue' }, { car: 'Chrysler', year: 2019, chassis: 'yellow', bumper: 'black' }, { car: 'Volvo', year: 2020, chassis: 'white', bumper: 'gray' }, ];
readonly gridSettings: GridSettings = { height: 'auto', colHeaders: ['Car', 'Year', 'Chassis color', 'Bumper color'], autoWrapRow: true, autoWrapCol: true, columns: [ { data: 'car', editor: false, }, { data: 'year', editor: 'numeric', }, { data: 'chassis', editor: 'text', }, { data: 'bumper', editor: 'text', }, ] };}/* end-file */
/* file: app.config.ts */import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';import { registerAllModules } from 'handsontable/registry';import { HOT_GLOBAL_CONFIG, HotGlobalConfig, NON_COMMERCIAL_LICENSE } from '@handsontable/angular-wrapper';
// register Handsontable's modulesregisterAllModules();
export const appConfig: ApplicationConfig = { providers: [ provideZoneChangeDetection({ eventCoalescing: true }), { provide: HOT_GLOBAL_CONFIG, useValue: { license: NON_COMMERCIAL_LICENSE } as HotGlobalConfig, }, ],};/* end-file */<div> <example3-disabled-cells></example3-disabled-cells></div>To disable a cell
To make specific cells non-editable, set editor: false in the cell configuration. The following example shows a table with non-editable cells containing the word “Nissan”.
/* file: app.component.ts */import { AfterViewInit, Component, ViewChild } from '@angular/core';import { GridSettings, HotTableComponent, HotTableModule } from '@handsontable/angular-wrapper';
@Component({ selector: 'example4-disabled-cells', standalone: true, imports: [HotTableModule], template: ` <div> <hot-table [data]="data" [settings]="gridSettings"></hot-table> </div>`,})export class AppComponent implements AfterViewInit { @ViewChild(HotTableComponent, { static: false }) readonly hotTable!: HotTableComponent;
readonly data = [ { car: 'Tesla', year: 2017, chassis: 'black', bumper: 'black' }, { car: 'Nissan', year: 2018, chassis: 'blue', bumper: 'blue' }, { car: 'Chrysler', year: 2019, chassis: 'yellow', bumper: 'black' }, { car: 'Volvo', year: 2020, chassis: 'white', bumper: 'gray' }, ];
readonly gridSettings: GridSettings = { height: 'auto', colHeaders: ['Car', 'Year', 'Chassis color', 'Bumper color'], autoWrapRow: true, autoWrapCol: true };
ngAfterViewInit(): void { const hot = this.hotTable?.hotInstance;
hot?.updateSettings({ cells: (row, _col, prop) => { if (hot.getDataAtRowProp(row, prop as string) === 'Nissan') { return { editor: false }; } return { editor: 'text' }; }, }); }}/* end-file */
/* file: app.config.ts */import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';import { registerAllModules } from 'handsontable/registry';import { HOT_GLOBAL_CONFIG, HotGlobalConfig, NON_COMMERCIAL_LICENSE } from '@handsontable/angular-wrapper';
// register Handsontable's modulesregisterAllModules();
export const appConfig: ApplicationConfig = { providers: [ provideZoneChangeDetection({ eventCoalescing: true }), { provide: HOT_GLOBAL_CONFIG, useValue: { license: NON_COMMERCIAL_LICENSE } as HotGlobalConfig, }, ],};/* end-file */<div> <example4-disabled-cells></example4-disabled-cells></div>Related API reference
Configuration options
Result
Read-only cells display with the htDimmed CSS class and block paste and drag-to-fill operations. Non-editable cells block manual editing but allow copy-paste and drag-to-fill.