I got a grid that displays orders and details
This is the main grid:
@(
Html.Kendo().Grid<BoWeb.Web.Models.OrderModel>().Name("gridOrders")
.Sortable()
.Scrollable()
.Columns(cols =>{
cols.Bound(col => col.OrderNr);
cols.Bound(col => col.CreateDate).Format("{0:dd.MM.yyyy hh:mm}");
cols.Bound(col => col.PaymentResource);
cols.Bound(col => col.ShippingResource);
cols.Bound(col => col.ShippingSurcharge);
cols.Bound(col => col.TotalIncl);
})
.ClientDetailTemplateId("tmplOrderItem")
.DataSource(ds => ds
.Ajax()
.Read(r => r.Url("/Customer/Admin?handler=ReadOrders").Data("forgeryToken"))
.Model(m =>{
m.Id(id => id.PKOrder);
})
)
.Deferred()
)
This works fine.
The template looks like this:
<script id="tmplOrderItem" type="text/kendo-tmpl">
@(
Html.Kendo().Grid<BoWeb.Web.Models.OrderItem>().Name("gridCart_#=PKOrder#")
.Sortable()
.Editable(edit => edit.Mode(GridEditMode.InLine))
.Columns(cols =>{
cols.Bound(col => col.Quantity).EditorTemplateName("IntegerEditor");
cols.Bound(col => col.Caption);
cols.Bound(col => col.SinglePriceIncl);
cols.Bound(col => col.TotalPriceIncl);
cols.Command(col =>
{
col.Edit().Text(" ").UpdateText(" ").CancelText(" ");
}).Width(120);
})
.DataSource(ds => ds
.Ajax()
.Read(r => r.Url("/Customer/Admin?handler=ReadOrderItems&orderId=#=PKOrder#").Data("forgeryToken"))
.Update(u => u.Url("/Customer/Admin?handler=UpdateOrderItem").Data("forgeryToken"))
.Model(m =>
{
m.Id(id => id.FKSubItem);
m.Field(f => f.Quantity);
m.Field(f => f.Caption).Editable(false);
m.Field(f => f.SinglePriceIncl).Editable(false);
m.Field(f => f.TotalPriceIncl).Editable(false);
})
)
.ToClientTemplate()
)
</script>
The read works. No problem and data is displayed correctly.
But the update-handler is not called.
The handler looks like this:
public JsonResult OnPostUpdateOrderItem([DataSourceRequest]DataSourceRequest request, OrderItem item)
{
if(item != null && ModelState.IsValid)
{
}
return new JsonResult(new[] { item }.ToDataSourceResult(request, ModelState));
}
I also inject Xsrf and added
@Html.AntiForgeryToken()
Of course there is also the
@Html.Kendo().DeferredScripts()
Any ideas why this is not working?