I have a small Kendo grid configured as shown below. In an incredibly cryptic key, the Controller action for "Add New", i.e. BatchCreate , is called only when you press the button of another command after clicking "Add new". For instance. a) Click "Add New", nothing happens. b) Reload the page and click "Add New" and nothing will work, then click "Save Changes", then the BatchCreate method will be BatchCreate .
My grid looks like this, copied almost directly from an example of them:
@(Html.Kendo().Grid<LocationIndexItem>() .Name("index-grid") .Columns(columns => { columns.Bound(p => p.Name); columns.Bound(p => p.IsActive).ClientTemplate( "<input type='checkbox' value='#= IsActive #' " + "# if (IsActive) { #" + "checked='checked'" + "# } #" + "/>").Width(70); columns.Bound(p => p.Remarks); columns.Command(cmd => cmd.Destroy()); }) .ToolBar(toolbar => { toolbar.Create(); toolbar.Save(); }) //.Events(e => e.Edit("gridEdit")) .Editable(editable => editable.Mode(GridEditMode.InCell)) .Filterable() .Pageable() .Scrollable() .DataSource(dataSource => dataSource .Ajax() .ServerOperation(false) .Batch(true) .PageSize(20) .Events(events => events.Error("errorHandler")) .Model(model => model.Id(p => p.Id)) .Read(read => read.Action("Read", "Location")) .Update(update => update.Action("BatchUpdate", "Location")) .Create(create => create.Action("BatchCreate", "Location")) .Destroy(destroy => destroy.Action("BatchDelete", "Location")) ) )
The other grid is exactly the same, with the exception of one additional field, it works fine.
JUST IN: Filtering the grid with the following code seems to trigger the behavior described above. When I comment out a commented line, $("#ParkadeId").change() out, the grid behaves as usual:
$(function() { $("#ParkadeId").change(function () { var value = $(this).val(); var grid = $("#index-grid").data("kendoGrid"); if (value) { grid.dataSource.filter({ field: "ParkadeId", operator: "eq", value: parseInt(value) }); } else { grid.dataSource.filter({}); } });
It would seem that installing a filter in the Kendo grid interrupts the Add New function.
Profk source share