Error "Cannot Read Properties of Undefined (reading 'index')" in Grid
Environment
| Product | Progress® Kendo UI for Angular Grid |
Description
I encounter the error Cannot read properties of undefined (reading 'index') after updating my Angular app to v21. The error originates from ScrollerService2.onScroll in the Grid component.
Cause
Angular v21 enables zoneless mode by default, which affects some Kendo UI for Angular components. The Kendo UI for Angular components currently do not support zoneless mode. This mismatch triggers the error during certain operations like scrolling.
Solution
To resolve the issue, follow these steps to disable zoneless mode:
-
Install
zone.jsusing npm:bashnpm install zone.js -
Add
zone.jsto thepolyfillssection of theangular.jsonfile:json"styles": [ "src/styles.css" ], "polyfills": [ "@angular/localize/init", "zone.js" ] -
Update the
app.config.tsfile to include theprovideZoneChangeDetectionfunction:typescriptimport {ApplicationConfig, importProvidersFrom, provideBrowserGlobalErrorListeners, provideZoneChangeDetection} from '@angular/core'; import { provideRouter } from '@angular/router'; import { provideAnimations } from '@angular/platform-browser/animations'; import { routes } from './app.routes'; export const appConfig: ApplicationConfig = { providers: [ provideBrowserGlobalErrorListeners(), provideRouter(routes), provideZoneChangeDetection({ eventCoalescing: true }), provideAnimations() ], };
After you complete these steps, the Cannot read properties of undefined (reading 'index') error in the Kendo UI for Angular Grid is resolved.