kendo grid odd behaviour around service instantiation

0 Answers 41 Views
Grid
John
Top achievements
Rank 1
John asked on 16 Jan 2023, 11:50 AM | edited on 16 Jan 2023, 12:51 PM

I'm using a Kendo Grid in an Angular template and trying to allow a service in the component to define some css styling but having a problem.


<kendo-grid
*ngIf="canLoad()"
[data]=etc...
[rowClass] = "rowCallback"
>

public canLoad() : boolean
{
  return this.myservice !== undefined;
}

public rowCallback(context: RowClassArgs)
{
  this.myservice.doSomething();
}

I get an error "Cannot read properties of undefined (reading 'doSomething')" ... why do I get an error when the ngIf check has evaluated myservice as being instantiated? How can I get the rowCallback to wait until the service has been instantiated?

... also

I read a previous Telerik forum response where an employee stated

"The rowClass callback function is directly passed as a value to the ngClass directive,

which is then applied on each row." ... so just to see if my problem was a behaviour of Angular itself I

added <div [ngClass]="rowCallback()">testing...</div> and myService was available and the doSomething()

method was called.

No answers yet. Maybe you can help?

Tags
Grid
Asked by
John
Top achievements
Rank 1
Share this question
or