Using blazor server with latest Telerik Blazor package (currently 4.1.0).
I created a very simple CustomDropDownList.razor file with the following:
@typeparam TItem @typeparam TValue @inherits TelerikDropDownList<TItem, TValue>
and attempted to use the new component in a page:
@page "/test"
<CustomDropDownList Data="testData" @bind-Value="value" />
@code {
int? value = null;
private List<Model> testData = new List<Model>()
{
new Model() { Id = 1, Text = "Item 1" },
new Model() { Id = 2, Text = "Item 2" }
};
class Model
{
public int? Id { get; set; }
public string Text { get; set; }
}
}
I get the javascript error:
Cannot read properties of null (reading addEventListener)
I'm aware you have a page regarding this error, but it only suggests making sure telerik-blazor.js file is up to date. Mine is.
Now, if I define the same component in a .cs file instead of a .razor file, the scenario works fine:
public class CustomDropDownList<TItem, TValue> : TelerikDropDownList<TItem, TValue>
{
}
REPL with error (using .razor file): https://blazorrepl.telerik.com/GRaoFuvr00aqKiQq27
REPL that works (using .cs file): https://blazorrepl.telerik.com/wHkyFubg58jPmb8D40
So what is going on here?
Ultimately, I'm trying to inherit from TelerikDropDownList to encapsulate a reusable custom dropdown. I have done this with .cs files a number of times with no problem, but in this case I was wanting to define an ItemTemplate and it's much more practical to do .razor file - that's when I discovered this issue.