This is a migrated thread and some comments may be shown as answers.

Custom Edutor problem

1 Answer 157 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jimmy
Top achievements
Rank 1
Iron
Veteran
Jimmy asked on 12 Sep 2019, 09:01 AM

Hi

I follow the Kendo Core Grid Demo- Editing Custom Editor here https://demos.telerik.com/aspnet-core/grid/editing-custom

but when I click on the add record button, I got an error "Uncaught TypeError: Cannot read property 'CategoryName' of null"

I suspect is is due client template field name with a dot (.ClientTemplate("#=Category.CategoryName#"))

I even downloaded the demo sample file for both core and MVC to run it locally  and turn out MVC version work but .Net Core version has the same error.

Is this a bug in Core version? can anyone advice? Thank you

 

 

@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.ProductViewModel>()
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.ProductName);
        columns.Bound(p => p.Category).ClientTemplate("#=Category.CategoryName#").Sortable(false).Width(180);
        columns.Bound(p => p.UnitPrice).Width(130);
        columns.Command(command => command.Destroy()).Width(150);
    })
    .ToolBar(toolBar =>
        {
            toolBar.Create();
            toolBar.Save();
        })
    .Editable(editable => editable.Mode(GridEditMode.InCell))
    .Pageable()
    .Sortable()
    .Scrollable()
    .HtmlAttributes(new { style = "height:550px;" })
    .DataSource(dataSource => dataSource
        .Ajax()
        .Batch(true)
        .ServerOperation(false)
        .Events(events => events.Error("error_handler"))
        .Model(model =>
        {
            model.Id(p => p.ProductID);
            model.Field(p => p.ProductID).Editable(false);
            model.Field(p => p.Category).DefaultValue(
                ViewData["defaultCategory"] as Kendo.Mvc.Examples.Models.CategoryViewModel);
        })
        .PageSize(20)
        .Read(read => read.Action("EditingCustom_Read", "Grid"))
        .Create(create => create.Action("EditingCustom_Create", "Grid"))
        .Update(update => update.Action("EditingCustom_Update", "Grid"))        
        .Destroy(destroy => destroy.Action("EditingCustom_Destroy", "Grid"))
    )
)

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 13 Sep 2019, 11:35 AM
Hello Jimmy,

With the 2019 R2 release, there was a change which sets the model.nullable setting to true in case the type of the field is nullable. This change causes the default value to not apply. We are aware of the behavior a fix has been already introduced. It is included in our latest internal build which you can download from your account:

Please download the internal build and reference the dll in your project and let me know if the issue still occurs.

We apologize for the inconvenience this might have caused you.

Kind regards,
Nikolay
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Jimmy
Top achievements
Rank 1
Iron
Veteran
Answers by
Nikolay
Telerik team
Share this question
or