Angular Data GridCustom ID in Angular

Pass a custom ID to the hot-table component to further customize your Angular data grid.

On this page

Overview

Along with other attributes of the hot-table wrapper element, you can also pass a custom id. It will be applied to the root Handsontable element, allowing further customization of the table.

Example

/* file: app.component.ts */
import { Component } from '@angular/core';
import Handsontable from 'handsontable/base';

@Component({
  selector: 'app-root',
  template: `
    <div>
      <hot-table
        [settings]="hotSettings"
        [hotId]="id">
      </hot-table>
    </div>
  `,
})
export class AppComponent {
  hotSettings: Handsontable.GridSettings = {
    startRows: 5,
    startCols: 5,
    colHeaders: true,
    stretchH: 'all',
    height: 'auto',
    autoWrapRow: true,
    autoWrapCol: true,
    licenseKey: 'non-commercial-and-evaluation'
  };
  id = 'my-custom-id';
}


/* file: app.module.ts */
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HotTableModule } from '@handsontable/angular';
import { registerAllModules } from 'handsontable/registry';
import { AppComponent } from './app.component';

// register Handsontable's modules
registerAllModules();

@NgModule({
  imports: [ BrowserModule, HotTableModule ],
  declarations: [ AppComponent ],
  bootstrap: [ AppComponent ]
})

export class AppModule { }

There is a newer version of Handsontable available. Switch to the latest version ⟶