public ActionResult GetValues()
{
int page = 2;
string file = Server.MapPath("~/App_Data/Data.json");
//deserialize JSON from file
string objJson = System.IO.File.ReadAllText(file);
JavaScriptSerializer ser = new JavaScriptSerializer();
var personlist = ser.Deserialize<List<Person>>(objJson);
var jsonData = new
{
total = 10,
page,
records = 100,
rows = personlist
};
return Json(jsonData, JsonRequestBehavior.AllowGet);
}
$(document).ready(function ($) {
$('#tree').jqGrid({
"url": '/Home/GetValues/',
datatype: "json",
//contentType: "application/json; charset-utf-8",
colNames: ['City', 'FirstName', 'LastName', 'PersonId'],
colModel: [
{ name: 'City', index: 'City', width: 150 },
{ name: 'FirstName', index: 'FirstName', width: 150 },
{ name: 'LastName', index: 'LastName', width: 150 },
{ name: 'PersonId', index: 'PersonId', width: 150 }
],
//rowNum: 10,
loadonce: true
});
});