or
@(Html.Kendo().Grid<NewAlta.DataCapture.DataModel.ParameterOverride>() .Name("test") .Columns(columns => { columns.Bound(p => p.CustomerId).Hidden(); columns.ForeignKey(p => p.EquipmentId, (System.Collections.IEnumerable)ViewData["equipments"], "EquipmentId", "Description").Title("Equipment").EditorTemplateName("CustomerEquipmentId"); columns.ForeignKey(p => p.ParameterId, (System.Collections.IEnumerable)ViewData["parameters"], "ParameterId", "ParameterName").Title("Parameter").EditorTemplateName("ParameterId"); columns.Bound(p => p.Limit1).Width(100); columns.Bound(p => p.Limit2).Width(200); columns.Bound(p => p.Limit3).Width(200); columns.Bound(p => p.Limit4).Width(100); columns.Command(p => p.Edit()).Width(80); }) .ToolBar(toolbar => toolbar.Create()) .Editable(editable => editable.Mode(GridEditMode.InLine)) .AutoBind(false) // .Navigatable(builder => builder.Enabled(true)) .Events(events => { events.Change("test"); events.Edit("test"); events.Save("test"); }) .Selectable(builder => builder.Mode(GridSelectionMode.Single)) .DataSource(dataSource => dataSource .Ajax() .ServerOperation(false) .Events(e => e.Error("errorHandler"))// omitted for brevity<script type="text/javascript"> function errorHandler(e) { gridErrorHandler(e, "#test"); }//The below function lies in some js include files.function gridErrorHandler(args, gridId) { if (args.errors) { var message = "We have encountered following errors : \n <ul>"; $.each(args.errors, function (key, value) { if ('errors' in value) { $.each(value.errors, function () { //alert(this); if (this != "" && this != null) message += "<li>" + this + "</li> \n "; }); message += "</ul>"; } }); var kgrid = $(gridId).data("kendoGrid");
kgrid.one('dataBinding', function (e) { //==> if we have only one grid in the view this works. for mutiple grids in view it does not trigger e.preventDefault(); // cancel grid rebind if error occurs }); showAlertWindow(message); //==> Some other function used to show kendo window with errror messages. }}</script>@(Html.Kendo().Grid(Model) .Name("Grid") .HtmlAttributes(new { style = "font-size:.85em;" }) .Columns(columns => { columns.Bound(p => p.Id).Width(60); columns.Bound(p => p.Title).Width(250); columns.Bound(p => p.AssignedUser).Width(120); }) .Pageable() .Groupable() .Sortable() .Filterable(filterable => filterable .Extra(false) .Operators(operators => operators .ForString(str => str.Clear() .StartsWith("Starts with") .Contains("Contains") .IsEqualTo("Is equal to") .IsNotEqualTo("Is not equal to"))) ) .Selectable(selectable => selectable .Mode(GridSelectionMode.Single)) .DataSource(dataSource => dataSource .Ajax() .Read(read => read.Action("Get", "Grid", new {showAll = ViewBag.ShowAll})) ) .Events(e => e.Change("onChanged").DataBound("onDataBound")))public class Product { [Key] [ScaffoldColumn(false)] public int ProductId { get; set; } public string Name { get; set; } public int Number { get; set; } public virtual ICollection<PurchaseInvoiceDetail> PurchaseInvoiceDetail { get; set; } }public class PurchaseInvoiceDetail { [Key] public int PurchaseInvoiceDetailId { get; set; } public int Number { get; set; } public decimal PurchasePrice { get; set; } //Navigation Properties public int ProductId { get; set; } public virtual Product Product { get; set; } }window.app = new kendo.mobile.Application(document.body, { layout: "mainLayout", skin: "flat", hideAddressBar: true, icon: "Images/FileName.png", title: "App Name"});