Skip to content

Use the select cell type to collect user input with an HTML <select> element that creates a multi-item dropdown list.

The select cell type renders a native HTML <select> element. Consider using the dropdown cell type instead for autocomplete and search capabilities.

Overview

The select cell type is a simpler form of the dropdown cell type.

Usage

Note: The select editor is intended as a reference implementation for writing custom editors rather than as a fully-featured editor. It is a much simpler form of the Dropdown editor. Use the dropdown cell type in your projects for a better user experience.

TypeScript
/* file: app.component.ts */
import { Component } from '@angular/core';
import { GridSettings, HotTableModule} from '@handsontable/angular-wrapper';
@Component({
selector: 'example1-select-cell-type',
standalone: true,
imports: [HotTableModule],
template: ` <div>
<hot-table [data]="data" [settings]="gridSettings"></hot-table>
</div>`,
})
export class AppComponent {
readonly data = [
['2017', 'Honda', 10],
['2018', 'Toyota', 20],
['2019', 'Nissan', 30],
];
readonly gridSettings: GridSettings = {
height: 'auto',
colWidths: [50, 70, 50],
colHeaders: true,
autoWrapRow: true,
autoWrapCol: true,
columns: [
{},
{
type: 'select',
selectOptions: ['Kia', 'Nissan', 'Toyota', 'Honda'],
},
{},
]
};
}
/* 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 modules
registerAllModules();
export const appConfig: ApplicationConfig = {
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
{
provide: HOT_GLOBAL_CONFIG,
useValue: { license: NON_COMMERCIAL_LICENSE } as HotGlobalConfig,
},
],
};
/* end-file */
HTML
<div>
<example1-select-cell-type></example1-select-cell-type>
</div>

Result

After configuring the select cell type, cells render a native HTML <select> element when the user activates them. The user picks a value from the list and the selected value is written to the data source.

Related guides

Configuration options

Core methods

Hooks