Skip to content

Handsontable cell type

Add a spreadsheet editor in a popup, by using the Handsontable cell type.

The Handsontable cell type embeds a second grid instance as a cell editor (HOT-in-HOT). Use it when users need to search and select from a large dataset.

Usage

HOT-in-HOT opens by any of the following:

  • F2 or Enter key is pressed while the cell is selected
  • The triangle icon is clicked
  • The cell content is double clicked

While HOT-in-HOT is opened, the text field above the HOT-in-HOT remains focused at all times.

The nested grid is not the main grid, so the options that drive main-grid UI have no effect when you set them inside the handsontable option: dialog, notification, emptyDataState, pagination, and loading. Set them on the main grid instead. The same applies to the nested grid that the autocomplete and dropdown cell types open.

Basic example

The Product column uses the handsontable cell type for a searchable product list. The Category and Warehouse columns use the dropdown cell type for compact selection from a short list.

TypeScript
/* file: app.component.ts */
import { Component } from '@angular/core';
import { GridSettings, HotTableModule} from '@handsontable/angular-wrapper';
const productData = [
{ sku: 'SKU-4821', name: 'Stainless Steel Water Bottle', supplier: 'Harbor Goods' },
{ sku: 'SKU-0093', name: 'Wireless Mouse', supplier: 'Alpine Supply Co.' },
{ sku: 'SKU-1170', name: 'Ergonomic Office Chair', supplier: 'Cascade Distributors' },
{ sku: 'SKU-2208', name: 'USB-C Charging Cable', supplier: 'Summit Trading' },
{ sku: 'SKU-3341', name: 'Aluminum Water Filter', supplier: 'Northgate Wholesale' },
{ sku: 'SKU-4412', name: 'Canvas Tote Bag', supplier: 'Nordic Traders' },
{ sku: 'SKU-5088', name: 'USB-C Hub', supplier: 'Harbor Goods' },
{ sku: 'SKU-6120', name: 'Ceramic Mug Set', supplier: 'Alpine Supply Co.' },
{ sku: 'SKU-7294', name: 'Desk Lamp', supplier: 'Cascade Distributors' },
{ sku: 'SKU-8015', name: 'Laptop Stand', supplier: 'Summit Trading' },
{ sku: 'SKU-9166', name: 'Bluetooth Speaker', supplier: 'Northgate Wholesale' },
{ sku: 'SKU-1042', name: 'Standing Desk', supplier: 'Nordic Traders' },
];
@Component({
selector: 'example1-handsontable-cell-type',
standalone: true,
imports: [HotTableModule],
template: ` <div>
<hot-table [data]="data" [settings]="gridSettings"></hot-table>
</div>`,
})
export class AppComponent {
readonly data = [
['SKU-4821', 'Stainless Steel Water Bottle', 'Drinkware', 'Seattle'],
['SKU-0093', 'Wireless Mouse', 'Electronics', 'Denver'],
['SKU-1170', 'Ergonomic Office Chair', 'Furniture', 'Portland'],
['SKU-2208', 'USB-C Charging Cable', 'Electronics', 'Austin'],
['SKU-3341', 'Aluminum Water Filter', 'Drinkware', 'Minneapolis'],
];
readonly gridSettings: GridSettings = {
colHeaders: ['SKU', 'Product', 'Category', 'Warehouse'],
height: 'auto',
autoWrapRow: true,
autoWrapCol: true,
columns: [
{},
{
type: 'handsontable',
handsontable: {
colHeaders: ['SKU', 'Product', 'Supplier'],
autoColumnSize: true,
data: productData,
getValue() {
const selection = this.getSelectedLast();
// Get the product name of the clicked row and ignore header
// coordinates (negative values)
const row = this.getSourceDataAtRow(Math.max(selection?.[0] ?? 0, 0)) as { name: string };
return row.name;
},
},
},
{
type: 'dropdown',
source: ['Drinkware', 'Electronics', 'Furniture', 'Apparel'],
},
{
type: 'dropdown',
source: [
'Seattle',
'Denver',
'Portland',
'Austin',
'Minneapolis',
'Boston',
'Chicago',
'Phoenix',
'Atlanta',
'Dallas',
'San Jose',
'Columbus',
],
},
]
};
}
/* end-file */
/* file: app.config.ts */
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
import { registerAllModules } from 'handsontable/registry';
import { HOT_GLOBAL_CONFIG, HotGlobalConfig } from '@handsontable/angular-wrapper';
// register Handsontable's modules
registerAllModules();
export const appConfig: ApplicationConfig = {
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
{
provide: HOT_GLOBAL_CONFIG,
useValue: {
// license: 'your-license-key', // get a key at https://handsontable.com/pricing/
} as HotGlobalConfig,
},
],
};
/* end-file */
HTML
<div>
<example1-handsontable-cell-type></example1-handsontable-cell-type>
</div>

Keyboard shortcuts

KeyAction
EscapeClose editor and cancel change
EnterClose editor and apply change; move selection in the main HOT downwards or according to the enterMoves setting
TabSame as Enter, but move selection to the right or left according to the tabMoves setting
Arrow DownMove selection in HOT-in-HOT downwards. No effect if last row is selected
Arrow UpMove selection in HOT-in-HOT upwards. If the first row was selected, deselect. If HOT-in-HOT was deselected, behave as Enter but move main HOT selection upwards
Arrow RightMove text cursor in the text field to the left. If cursor was at start, behave as Enter but move main HOT selection to the left
Arrow LeftMove text cursor in the text field to the right. If cursor was at end, behave as Tab

For the full list of default keyboard shortcuts, see keyboard shortcuts.

Result

After configuring the Handsontable cell type, cells display a text input with a trigger icon. Activating the cell opens a second embedded grid that users can navigate and select from. The selected row value is written back to the parent cell.

Related guides

Configuration options

Core methods

Hooks