I have a models
Route:
int RouteID;
String RouteName;
IEnumerable<RouteCustomer> Customers;
RouteCustomer:
int RouteID;
int CustomerID;
int Sun;
int Mon;
int Tue;
int Wed;
int Thue;
int Fri;
int Sat;
Customer:
int CustomerID;
String Name;
I have created an edit form that allows changes (route name) and a grid for the customer information. What is happening now is that I am not getting the events I need when adding a new row to the grid:
Here is the grid code:
And here is the controller:
The events in the controller just don't seem to fire. I thought I copied it from the sample programs, but it doesn't seem to work correctly. Any help would be appreciated.
Route:
int RouteID;
String RouteName;
IEnumerable<RouteCustomer> Customers;
RouteCustomer:
int RouteID;
int CustomerID;
int Sun;
int Mon;
int Tue;
int Wed;
int Thue;
int Fri;
int Sat;
Customer:
int CustomerID;
String Name;
I have created an edit form that allows changes (route name) and a grid for the customer information. What is happening now is that I am not getting the events I need when adding a new row to the grid:
Here is the grid code:
@(Html.Kendo().Grid<LightRouteDB.RouteCustomer>() .Name("CustomerGrid") .Columns(cols => { cols.Bound(r => r.CustomerID); //cols.Bound(r => r.Customer.CustomerName); cols.Bound(r => r.Sun); cols.Bound(r => r.Mon); cols.Bound(r => r.Tue); cols.Bound(r => r.Wed); cols.Bound(r => r.Thu); cols.Bound(r => r.Fri); cols.Bound(r => r.Sat); cols.Command(command => { command.Edit(); command.Destroy(); }).Width(200); }) .ToolBar(toolbar => toolbar.Create()) .Editable(editable => editable.Mode(GridEditMode.InLine)) .Pageable() .Sortable() .Scrollable() .DataSource(ds => ds .Ajax() .Events(events => events.Error("error_handler")) .Model(m => { m.Id(p => p.RouteCustomerID); m.Field(f => f.RouteID).DefaultValue(Model.Route.RouteID); }) .Create(a => a.Action("CreateCustomerRow", "Routes")) .Read(r => r.Action("ReadCustomerRows", "Routes")) .Update(u => u.Action("UpdateCustomerRow", "Routes")) .Destroy(d => d.Action("DestroyCustomerRow", "Routes")) ) )public ActionResult ReadCustomerRows(int id, [DataSourceRequest] DataSourceRequest request) { return Json(getRouteCustomersFromSession().ToDataSourceResult(request)); } [AcceptVerbs(HttpVerbs.Post)] public ActionResult CreateCustomerRow(int id, [DataSourceRequest] DataSourceRequest request, RouteCustomer customer) { if (customer != null && ModelState.IsValid) { IList<RouteCustomer> rc = getRouteCustomersFromSession(); rc.Add(customer); } return Json(new[] { customer }.ToDataSourceResult(request, ModelState)); } [AcceptVerbs(HttpVerbs.Post)] public ActionResult UpdateCustomerRow([DataSourceRequest] DataSourceRequest request, RouteCustomer customer) { if (customer != null && ModelState.IsValid) { IList<RouteCustomer> rc = getRouteCustomersFromSession(); var target = rc.Where(c => c.RouteCustomerID == customer.CustomerID).First(); if (target != null) { target.CustomerID = customer.CustomerID; saveRouteCustomersToSession(rc); } } return Json(ModelState.ToDataSourceResult()); }The events in the controller just don't seem to fire. I thought I copied it from the sample programs, but it doesn't seem to work correctly. Any help would be appreciated.