Hi, iam using jqgrid using json result but grid is not populating plz help me
here is my code
for controller:
public JsonResult GetEmployeeData()
{
List<models.empdetails> emp = new List<models.empdetails>();
con.Open();
string query = "select * from EmpDetail where StatusTypeId=1 order by EmpId DESC";
SqlCommand cmd = new SqlCommand(query, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
cmd.CommandType = CommandType.Text;
DataSet ds = new DataSet();
da.Fill(ds);
foreach (DataRow dr in ds.Tables[0].Rows)
{
emp.Add(new Models.EmpDetails()
{
Name = dr[0].ToString(),
EmpId = Convert.ToInt32(dr[1].ToString()),
Salary = Convert.ToInt32(dr[2].ToString()),
Address = dr[3].ToString(),
ZipCode = Convert.ToInt32(dr[4].ToString()),
PhoneNumber = Convert.ToInt32(dr[5].ToString()),
Permanent = Boolean.Parse(dr[7].ToString()),
Birthday = Convert.ToDateTime(dr[8].ToString()),
Country = dr[9].ToString()
});
}
cmd.ExecuteNonQuery();
return Json(emp, JsonRequestBehavior.AllowGet);
}
jquery:
$(document).ready(function () {
$('#grd').jqGrid(
{
dataType: 'json',
height: 250,
mtype: 'Get',
url: '/Home/GetEmployeeData',
colNames: ['Name', 'Address', 'Salary', 'PhoneNumber', 'Zipcode', 'Permanent', 'Birthday', 'Country'],
colModel: [{ name: 'Name', index: 'Name', width: 80 },
{ name: 'Address', index: 'Address', width: 100 },
{ name: 'Salary', index: 'Salary', width: 60 },
{ name: 'PhoneNumber', index: 'PhoneNumber', width: 75 },
{ name: 'ZipCode', index: 'ZipCode', width: 75 },
{ name: 'Permanent', index: 'Permanent', width: 60 },
{ name: 'Birthday', index: 'Birthday', width: 75 },
{ name: 'Country', index: 'Country', width: 100 }
],
cation: 'EmplyoeeDetails',
pager: $('#pager'),
sortdesc: 'desc',
viewrecords: true
});
});