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

2

12

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"))
    )
)
Santamaria answered 22/8, 2013 at 17:3 Comment(0)
S
22

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!

Santamaria answered 22/8, 2013 at 17:39 Comment(1)
I did not get.. can explain more. how to send data to controller. if remover tootlBar.Save() how we will post data to conroller.Rath
W
0

change

.Editable(editable => editable.Mode(GridEditMode.InCell))

to

.Editable(editable => editable.Mode(GridEditMode.InLine))

and as you said remove toolBar.Save();

Witticism answered 28/9, 2021 at 17:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.