This question is locked. New answers and comments are not allowed.
Hello, I've implemented this example - batch editing - and it works great with one exception...The cancel button for me doesn't work - it doesn't eliminate the unsaved changes and present me with a fresh grid. It seems that nothing happens at all. I believe I've implemented the grid properly. Do you have any advice? Thanks
@(Html.Telerik().Grid(Model) .Name("Grid") .DataKeys(d => d.Add<int>(a => a.Id).RouteKey("Id")) .Columns(columns => { columns.Bound<int>(c => c.Id).Width(100).ReadOnly(); columns.Bound<string>(c => c.FirstName).Width(120); columns.Bound<string>(c => c.LastName).Width(200); columns.Bound<string>(c => c.Phone).Width(120); columns.Bound<string>(c => c.Street).Width(200); columns.Bound<string>(c => c.City).Width(100); columns.Bound<string>(c => c.Province).Width(75); columns.Bound<string>(c => c.PostalCode).Width(100); columns.Bound<string>(c => c.Email).Width(100); columns.Bound<bool>(c => c.OkToContact).Width(50) .ClientTemplate("<input type='checkbox' disabled='disabled' name='OkToContact' <#=OkToContact? checked='checked' : '' #> />"); columns.Command(commands => { commands.Delete(); }).Width(200); }) .DataBinding(dataBinding => dataBinding .Ajax() .Select("_SelectBatchEditing", "Home") .Update("_SaveBatchEditing", "Home") ) .ToolBar(commands => { commands.Insert(); commands.SubmitChanges(); }) .Sortable() .Pageable() .Scrollable(scrolling => scrolling.Height(494)).Footer(false) .Editable(editing => editing.Mode(GridEditMode.InCell)) .Editable(editing => editing.Mode(GridEditMode.InCell).DefaultDataItem(new ContactView { OkToContact = true })) .ClientEvents(events => events.OnDataBinding("Grid_onDataBinding").OnError("Grid_onError").OnSubmitChanges("Grid_onSubmitChanges")) )<script type="text/javascript"> function Grid_onSubmitChanges(e) { e.values.FirstName = $("#FirstName").val(); e.values.LastName = $("#LastName").val(); } function Grid_onError(args) { if (args.textStatus == "modelstateerror" && args.modelState) { var message = "Errors:\n"; $.each(args.modelState, function (key, value) { if ('errors' in value) { $.each(value.errors, function() { message += this + "\n"; }); } }); args.preventDefault(); alert(message); } } function Grid_onDataBinding(e) { var grid = $(this).data('tGrid'); if (grid.hasChanges()) { if (!confirm('You are going to lose any unsaved changes. Are you sure?')) { e.preventDefault(); } } }</script>