Hi team,
I spent 2 days trying to fix this problem, and searched in this forum many times but couldn’t find an answer.
I am creating/ returning a JSON from my controller as the following:
private JsonResult GetCustomers()
{
var customers = from s in db.Customers
select s;
var retValue = customers.Select(
x => new
{
id = x.CustomerId,
fname = x.First_Name,
lname= x.Last_Name
}).ToList();
JavaScriptSerializer serializer = new JavaScriptSerializer();
return Json(new { Data = serializer.Serialize(retValue) }, JsonRequestBehavior.AllowGet);
}
the returned JSON is:
{“Data”:{“ContentEncoding”:null,“ContentType”:null,“Data”:{“Data”:"[{“id”:14,“fname”:“Sim”,“lname”:“Yoak”},{“id”:15,“fname”:“Cheel”,“lname”:“Pink”},{“id”:16,“fname”:“Pa Poon”,“lname”:“Chok”},“JsonRequestBehavior”:0,“MaxJsonLength”:null,“RecursionLimit”:null}}
on the view i have:
mygrid.load("/Home/GetCustomers", “jsarray”);
I also tried : mygrid.load("/Home/GetCustomers", “js”); and no luck
Am i missing something here? all i need is to load the data from my model to the Grid