This is a migrated thread and some comments may be shown as answers.

context menu on grid error - cannot set clickclick for undefined

1 Answer 395 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
rk
Top achievements
Rank 1
rk asked on 02 May 2018, 10:01 PM

I have an error when grid component is set a context menu. Took the  grid-context-menu.component.ts code and pasted as is from tutorial, but  it errors out in that file while setting cellclick input for #grid. Please find the attached image for error.

To build a context menu for grid, I was following the implementation at https://www.telerik.com/kendo-angular-ui/components/grid/advanced-features/context-menu

my gridcomponent:

<kendo-grid #grid
[data]="gridView"
(cellClick)="cellClickHandler($event)"
(cellClose)="cellCloseHandler($event)">

 <grid-context-menu [for]="grid" [menuItems]="contextmenuItems" (select)="onContextMenuClick($event)">
</grid-context-menu>

Error part: grid-context-menu.component.ts

@Input() public set for(grid: GridComponent) {
 this.unsubscribe();
 this.cellClickSubscription = grid.cellClick.subscribe(this.onCellClick);
}

 

Note: Even my grid component is named 'GridComponent' same as the one in gridModule. Thought that would be an issue and tested by renaming it. But found thats not an issue.

 

1 Answer, 1 is accepted

Sort by
0
Dimiter Topalov
Telerik team
answered on 04 May 2018, 10:33 AM
Hi RK,

I tried to replicate the described issue, but could not do so based on the provided information. Here is a sample application, based on the same example, that works as expected:

https://stackblitz.com/edit/angular-p9vqt3?file=app/grid-context-menu.component.ts

The JavaScript error suggest that the Grid component instance is not received properly in the ContextMenu component but we cannot infer why is this happening, based on the provided information. Are all necessary imports present, e.g.:

import { Component, ContentChild, EventEmitter, Input, Output, OnDestroy, Renderer2, TemplateRef } from '@angular/core';
import { Subscription } from 'rxjs/Subscription';
import { GridComponent } from '@progress/kendo-angular-grid';

Please compare the runnable example above to your implementation and apply the necessary adjustments (if any). If the issue persists, we will need a similar isolated runnable project where it can be observed, so we can inspect it further, and determine what might be causing it. Thank you in advance.

Regards,
Dimiter Topalov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
General Discussions
Asked by
rk
Top achievements
Rank 1
Answers by
Dimiter Topalov
Telerik team
Share this question
or