This question is locked. New answers and comments are not allowed.
I've spent the entire day figuring why this doesn't work. Everything is generated properly scripts are loaded, the browser (IE9, Chrome) steps into the tGrid() function when the document loads up, data is retrieved by the Select action, but the AJAX functions are unresponsive (edit, delete, insert, refresh) ie. I click on Edit and the row doesn't change into edit mode. I've skipped some of the code for brevity(namespaces, datacontext, irrelevant actions since the problem is with the Grid not the controller actions)
ASP.NET MVC2 with Telerik Q1 2011
Model:
Controller Actions:
View:
ASP.NET MVC2 with Telerik Q1 2011
Model:
[KnownType(typeof(ParticipantEditModel))]public class ParticipantEditModel{ [Required] public string Name { get; set; } [Required] public int? Number { get; set; } [Required] public int Quantity { get; set; }}[GridAction]public ActionResult GridIndex(int cusipID){ var cusip = _db.Cusips.SingleOrDefault(c => c.CusipID == cusipID); if (cusip == null) throw new NotFoundException(); return View(new GridModel(cusip.Participants.Select(p=>new ParticipantEditModel(p))));}[GridAction]public ActionResult GridInsert(int cusipID, ParticipantEditModel model){ var cusip = _db.Cusips.SingleOrDefault(c => c.CusipID == cusipID); if (cusip == null) throw new NotFoundException(); var participant = new Participant(); participant.UpdateWithModel(model); cusip.Participants.Add(participant); _db.SubmitChanges(); return View(new GridModel(cusip.Participants.Select(p => new ParticipantEditModel(p))));}[GridAction]public ActionResult GridUpdate(int cusipID, int id, ParticipantEditModel model){ var cusip = _db.Cusips.SingleOrDefault(c => c.CusipID == cusipID); if (cusip == null) throw new NotFoundException(); var participant = cusip.Participants.Single(p => p.Number == id); participant.UpdateWithModel(model); _db.SubmitChanges(); return View(new GridModel(cusip.Participants.Select(p => new ParticipantEditModel(p))));}[GridAction]public ActionResult GridDelete(int cusipID, int id, ParticipantEditModel model){ var cusip = _db.Cusips.SingleOrDefault(c => c.CusipID == cusipID); if (cusip == null) throw new NotFoundException(); var participant = cusip.Participants.Single(p => p.Number == id); _db.Participants.DeleteOnSubmit(participant); _db.SubmitChanges(); return View(new GridModel(cusip.Participants.Select(p => new ParticipantEditModel(p))));}View:
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<EagleRock.Models.Views.Cusip.EditModel>" %><%@ Import Namespace="EagleRock.Models.Views.Cusip" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title></head><body> <div> <% Html.Telerik().Grid<ParticipantEditModel>() .Name("Grid") .DataKeys(dk => dk.Add(c => c.Number)) .DataBinding(db => db.Ajax() .Select("GridIndex", "Cusip") .Insert("GridInsert", "Cusip") .Update("GridUpdate", "Cusip") .Delete("GridDelete", "Cusip") ) .Columns(c => { c.AutoGenerate(true); c.Command(b => { b.Edit(); b.Delete(); }); }) .Editable(e => e.Mode(GridEditMode.InLine)) .Render(); %> </div> <% Html.Telerik().ScriptRegistrar() .Render(); %></body></html>