This question is locked. New answers and comments are not allowed.
Hello,
I created controller using Data entity model. after that I m using this code
@(Html.Telerik().Grid<griddemo.Person>()
.Name("Grid")
.ToolBar(commands => commands.Insert())
.DataKeys(keys => keys.Add(c => c.Id))
.DataBinding(dataBinding => dataBinding
.Ajax()
.Select("_TemplatesClientSide", "Gridclient")
.Insert("Create", "Gridclient")
.Update("_Edit", "Gridclient")
.Delete("Delete", "Gridclient"))
.Columns(columns =>
{
columns.Bound(o => o.Id).Width(100);
columns.Bound(o => o.Name).Width(230);
columns.Bound(o => o.Address).Width(150);
columns.Command(commands => commands.Edit()).Title("Edit").Width(200);
columns.Command(cmd => cmd.Delete()).Title("Delete").Width(200);
})
.Pageable()
.Sortable()
)
and my controller is
public class GridclientController : Controller
{
private CustomerEntities db = new CustomerEntities();
//
// GET: /Gridclient/
public ActionResult AjaxBinding()
{
return View();
}
[GridAction]
public ActionResult _AjaxBinding()
{
return View(new GridModel(db.People.ToList()));
}
// new GridModel(db.People.ToList()) this is for client
public ActionResult TemplatesClientSide()
{
return View();
}
[GridAction]
public JsonResult _TemplatesClientSide()
{
return Json(new GridModel(db.People.ToList()));
}
public ViewResult Index()
{
//IEnumerable<Person> obj = db.People.ToList();
return View(db.People.ToList());
}
//
// GET: /Gridclient/Details/5
public ViewResult Details(int id)
{
Person person = db.People.Single(p => p.Id == id);
return View(person);
}
//
// GET: /Gridclient/Create
public ActionResult Create()
{
return View();
}
//
// POST: /Gridclient/Create
[HttpPost]
[GridAction]
public ActionResult Create(Person person)
{
if (ModelState.IsValid)
{
db.People.AddObject(person);
db.SaveChanges();
return RedirectToAction("_TemplatesClientSide");
}
return View(person);
}
//
// GET: /Gridclient/Edit/5
public JsonResult Edit(int id)
{
Person person = db.People.Single(p => p.Id == id);
return Json(person);
}
//
// POST: /Gridclient/Edit/5
[HttpPost]
[AcceptVerbs(HttpVerbs.Post)]
// [CultureAwareAction]
[GridAction]
public ActionResult _Edit(Person person)
{
if (ModelState.IsValid)
{
db.People.Attach(person);
db.ObjectStateManager.ChangeObjectState(person, EntityState.Modified);
db.SaveChanges();
return RedirectToAction("TemplatesClientSide");
}
return Json(person);
}
//
// GET: /Gridclient/Delete/5
public ActionResult Delete(int id)
{
Person person = db.People.Single(p => p.Id == id);
return View(person);
}
//
// POST: /Gridclient/Delete/5
[HttpPost, ActionName("Delete")]
public ActionResult DeleteConfirmed(int id)
{
Person person = db.People.Single(p => p.Id == id);
db.People.DeleteObject(person);
db.SaveChanges();
return RedirectToAction("_TemplatesClientSide");
}
}
I m getting error of json
Error! The requested URL did not return JSON
for Editng Inserting
Plz Help me . I m Stuck In this problem