Reputation: 97717
I get the following Kendo js error and stack trace from a page with a Kendo Grid with the error coming in about once or twice a day at random from end users:
Message: Cannot read property 'offsetTop' of null
at offsetTop line 28097, column 35 (/source//kendo.all.js:28097)
var itemHeight = $(element.children[0]).height(); var itemIndex = Math.floor(scrollTop / itemHeight) || 0; var item = element.children[itemIndex] || element.lastChild; var forward = item.offsetTop < scrollTop; while (item) { if (forward) { if (item.offsetTop + itemHeight > scrollTop || !item.nextSibling) {
at _firstVisibleItem line 28127, column 39 (/source//kendo.all.js:28127)
if (!template) { return; } var visibleItem = this._firstVisibleItem(); if (visibleItem) { this.header.html(template(visibleItem.group)); }
at _renderHeader line 27650, column 29 (/source//kendo.all.js:27650)
var that = this; clearTimeout(that._scrollId); that._scrollId = setTimeout(function () { that._renderHeader(); }, 50); }, this); },
It's not clear if the error is having any impact, but any error is disturbing and takes up room in our error log. My best guess is that the error occurs while the user is navigating away from the page. Perhaps there is a way to dispose of the grid safely without issue, though the problem could be something else entirely.
I'm using the latest Kendo release from January 2017, but I've seen it on previous versions as well.
Is there anything that can be done to eliminate this error, or can it be safely ignored?
Upvotes: 1
Views: 2260
Reputation: 3872
This error occurs probably because the grid isn't completely loaded in the DOM when a piece of your code is running and using some functionality of the grid.
What you need to do to find the cause is go further down the call-stack to the first appearance of a function in your code and not Kendo's.
I had a similar error happen to me. I'm using angular2 and tried using a Kendo Scheduler's functionality before the view was ready.
Upvotes: 2