This question is locked. New answers and comments are not allowed.
Hello,
I am trying to databind a grid using ajax. When I am trying to run the code while debugging none of the commands like Update are firing in my controller.
Here is my code - any ideas why the controller functions are not called when i click "Update". Furthermore, why the _AjaxSelect() is not fired either to populate the grid with data?
Here is my View:
Here is my controller:
Thanks in advance.
I am trying to databind a grid using ajax. When I am trying to run the code while debugging none of the commands like Update are firing in my controller.
Here is my code - any ideas why the controller functions are not called when i click "Update". Furthermore, why the _AjaxSelect() is not fired either to populate the grid with data?
Here is my View:
@(Html.Telerik().Grid<ADTool.Models.Monthly_Workorders>() .Name("Test") .ToolBar(commands => commands.Insert()) .DataKeys(datakeys => { datakeys.Add(p => p.monthly_workorder_year).RouteKey("monthly_workorder_year"); datakeys.Add(p => p.monthly_workorder_month).RouteKey("monthly_workorder_month"); datakeys.Add(p => p.project_id).RouteKey("project_id"); datakeys.Add(p => p.workorder_id).RouteKey("workorder_id"); datakeys.Add(p => p.department_id).RouteKey("department_id"); }) .Columns(columns => { columns.Bound(c => c.project_id).Title("project").Width(10); columns.Bound(c => c.workorder_id).Title("work order").Width(10); columns.Bound(c => c.department_id).Title("department").Width(10); columns.Bound(c => c.monthly_workorder_year).Title("year").Width(5); columns.Bound(c => c.monthly_workorder_month).Title("month").Width(5); columns.Bound(c => c.ac_hours).Width(10).Title("ac"); columns.Bound(c => c.correction_hours).Width(10).Title("extra"); columns.Bound(c => c.etc_hours).Width(10).Title("etc"); columns.Bound(c => c.eac_hours).Width(10).Title("eac"); columns.Bound(c => c.payment_plan).Width(10).Title("plan"); columns.Bound(c => c.hour_rate).Width(10).Title("rate"); columns.Command(commands => { commands.Edit(); commands.Delete(); }).Width(200).Title("Commands"); }) .DataBinding(dataBinding => dataBinding .Ajax() .Select("_AjaxSelect", "Test") .Insert("_AjaxInsert", "Test") .Update("_AjaxSave", "Test") .Delete("_AjaxSelect", "Test") ) .Filterable() .Sortable() .Pageable() .Groupable())Here is my controller:
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;using Telerik.Web.Mvc;using ADTool.Models;namespace ADTool.Controllers{ public class TestController : Controller { private ADToolEntities db = new ADToolEntities(); public ActionResult Index() { return View(); } [GridAction] public ActionResult _AjaxSelect() { return View(new GridModel(db.Monthly_Workorders)); } [AcceptVerbs(HttpVerbs.Post)] [GridAction] public ActionResult _AjaxSave(int id) { return View(new GridModel(db.Monthly_Workorders)); } [AcceptVerbs(HttpVerbs.Post)] [GridAction] public ActionResult _AjaxInsert() { return View(new GridModel(db.Monthly_Workorders)); } }}Thanks in advance.