Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception in KendoUI Grid InCell edit required for batch updates with batch set to false

I am getting an exception while trying to use the KendoUI Grid for an ASP.NET MVC (.net 4.5) app being developed in Visual Studio 2013. I've configured the grid to use InLine editing and have explicitly set Batch to false in the data source section. This is being rendered as a partial view. It should be noted that if GridEditMode.InLine is set to GridEditMode.InCell no exception is thrown.

Exception

You must use InCell edit mode for batch updates.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NotSupportedException: You must use InCell edit mode for batch updates.

CODE

@using Kendo.Mvc.UI
@model MyApp1.Data.DataModels.Agent

@(Html.Kendo().Grid<MyApp1.Data.ViewModels.PhoneNumberVM>()
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.Number);
        columns.Bound(p => p.Description);
        columns.Command(command => command.Edit()).Width(90);
        columns.Command(command => command.Destroy()).Width(90);
    })
    .ToolBar(toolBar =>
        {
            toolBar.Create().Text("Add Phone Number");
            toolBar.Save();
        })
    .Editable(editable => editable.Mode(GridEditMode.InLine))
    .DataSource(dataSource => dataSource
        .Ajax()
        .Batch(false)
        .Events(events => events.Error("error_handler"))
        .Model(model =>
        {
            model.Id(p => p.PhoneNumberId);
            model.Field(p => p.PerId).Editable(false).DefaultValue(@Model.PerId);
        })
        .Read(read => read.Action("_GetPhones", "Pers", new { AgentId = Model.AgentId }))
        .Create(create => create.Action("_AddPhone", "Pers"))
        .Update(update => update.Action("_EditPhone", "Pers"))
        .Destroy(destroy => destroy.Action("_DeletePhone", "Pers"))
    )
)
like image 838
RSolberg Avatar asked Aug 22 '13 17:08

RSolberg


1 Answers

I've resolved this...

In the toolbar I had the following command toolBar.Save() which appears to have told the control that it was going to be in a batch edit mode of some kind. By removing this I'm now able to get the behavior I want...

Copy and pasting examples is dangerous!

like image 126
RSolberg Avatar answered Sep 27 '22 21:09

RSolberg