Hello, I’m using handsontable@9.x inside my Angular project. With a custom renderer I want to trigger an angular router navigation but the router reference is undefined inside the afterOnCellMouseDown function. Is handsontable misconfigured or I’m trying to use an unsupported feature?
Here is what I have:
- in template… <hot-table … [afterOnCellMouseDown]=“handleMouseDown”>…
- in component ngOnInit Handsontable.renderers.registerRenderer(‘browsebutton’, this.browseButtonRenderer);
- in component body
private browseButtonRenderer(hotInstance: any, td: any, row: any, column: any, prop: any, value: any, cellProperties: any): any {
let btn = null;
btn = document.createElement(‘BUTTON’);
btn.textContent = ‘GO’;
btn.setAttribute(‘value’, value);
td.innerText = ‘’;
td.appendChild(btn);
return td;
}
public handleMouseDown(event: any): void {
const target = event.target as HTMLInputElement;
if (target.nodeName.toLowerCase() === ‘button’) {
this.router.navigate([‘other’,‘route’,target.value]); // this.router is UNDEFINED!
}
}
Thanks for your help