Hansontable not working in angular 12

Tags: #<Tag:0x00007f8b1dd51d58>

I am using angular 12 but Hansontable context and formula not working .

Hi @dinesh.venkatraman

Can you please specify what is your issue exactly? Preferably with code demo.

Hi @adrian.szymanski thanks for your reply.

Here I have attached my code.

Am added contextMenu but not working.

app.module.ts

import { NgModule } from ‘@angular/core’;

import { BrowserModule } from ‘@angular/platform-browser’;

import { AppRoutingModule } from ‘./app-routing.module’;

import { AppComponent } from ‘./app.component’;

import { HotTableModule } from ‘@handsontable/angular’;

import { registerAllModules } from ‘handsontable/registry’;

@NgModule({

declarations: [

AppComponent

],

imports: [

BrowserModule,

AppRoutingModule,

HotTableModule

],

providers: [],

bootstrap: [AppComponent]

})

export class AppModule { }

app.component.html

<hot-table

[data]="dataset"

[colHeaders]="true"

[rowHeaders]="true"

[contextMenu]="true"

height="auto"

licenseKey="non-commercial-and-evaluation">

  <hot-column data="id" [readOnly]="true" title="ID"></hot-column>

  <hot-column data="name" title="Full name"></hot-column>

  <hot-column data="address" title="Street name"></hot-column>

app.component.ts

import { Component } from ‘@angular/core’;

import Handsontable from ‘handsontable/base’;

import { ContextMenu } from ‘handsontable/plugins’;

@Component({

selector: ‘app-root’,

templateUrl: ‘./app.component.html’,

styleUrls: [’./app.component.css’]

})

export class AppComponent {

title = ‘hansontablesample’;

dataset: any[] = [

{id: 1, name: 'Ted Right', address: 'Wall Street'},

{id: 2, name: 'Frank Honest', address: 'Pennsylvania Avenue'},

{id: 3, name: 'Joan Well', address: 'Broadway'},

{id: 4, name: 'Gail Polite', address: 'Bourbon Street'},

{id: 5, name: 'Michael Fair', address: 'Lombard Street'},

{id: 6, name: 'Mia Fair', address: 'Rodeo Drive'},

{id: 7, name: 'Cora Fair', address: 'Sunset Boulevard'},

{id: 8, name: 'Jack Right', address: 'Michigan Avenue'},

];

}

Hi @dinesh.venkatraman

Here’s the same example in jsfiddle and it works just fine with contextMenu enabled. I also tested it locally and again, no problems. What is your environment?

https://jsfiddle.net/aszymanski/L2x9v5cz/

I am using latest angular package locally(only frontend).

currently its working with below code.

this.hotRegisterer.getInstance(this.hotpicklist).render();

Hi @dinesh.venkatraman

The line of code you sent is not connected in any way to the contextMenu option. Can you please send me a package with your local project?

https://drive.google.com/file/d/1PRV7lCVppz7JcEQ08ej8bnJMcpI1j-xU/view?usp=sharing

have attached my project code.

As @adrian.szymanski is doing one check for me I wanted to help here.

@dinesh.venkatraman you are missing the

registerAllModules();

call in the app.module.ts file. You can read more about it here https://handsontable.com/docs/angular-installation/#install-with-npm

Hi @adrian.szymanski @aleksandra_budnik thanks for your help.

Its working perfectly.