VM53633:3UncaughtTypeError: Cannot read properties ofnull (reading 'Name')
at eval (eval at compile (kendo.all.js:307701:86), <anonymous>:3:239)
at init._displayCell (kendo.all.js:307701:86)
at init.closeCell (kendo.all.js:307701:86)
at i (kendo.all.js:307701:86)
at kendo.all.js:307701:86
I found that I can specify default model value simply:
public Department Department { get; set; } = new Department();
This way, I can bind to object's property. But when I modify editor to include:
I get:
VM53633:3 Uncaught TypeError: Cannot read properties of null (reading 'Name') at eval (eval at compile (kendo.all.js:307701:86), <anonymous>:3:239) at init._displayCell (kendo.all.js:307701:86) at init.closeCell (kendo.all.js:307701:86) at i (kendo.all.js:307701:86) at kendo.all.js:307701:86
Full editor's code:
@(Html.Kendo().ComboBoxFor(m => m) .DataTextField("Name") .DataValueField("Id") .Filter(FilterType.Contains) .HtmlAttributes(new { data_bind = "value: Department" }) .DataSource(source => { source.Read(read => { read.Action("GetDepartments", "Home"); }); }))
Department:
public class Department : Entity { public string Name { get; set; } = string.Empty; public virtual List<User> Users { get; set; } public virtual List<Project> Projects { get; set; } }
Without call to HtmlAttributes in editor, anything runs without exceptions, but instead of showing Name's value, grid shows [Object object].
I'm using telerik 2022.1.301 with .net core 3.1.