嗨,我有一个简单的actinReault,它返回jsonResult。方法如下。
[HttpPost]
public JsonResult AllEmployees()
{
EmployeeService employeeService = new EmployeeService();
List<EmployeeViewModel> employeesViewMod = employeeService.allEmployee();
var AllEmpObjects= JsonConvert.SerializeObject(employeesViewMod);
return Json(AllEmpObjects);
}我们可以在来自DB的AllEmpObjects上调试和查看数据。
“{\”FirstName\:\“shuvo\”,\"LastName\":\"ahmed\",\“Address2 1”:\“110,uttra\",\”Address2 2\“:\”mymansing\“,\"HomePhone\":1234,\”MobileNo“:2345,\”suvo@yahoo.com\“:\”suvo@yahoo.com\“,\”道布“:”10/01/1977“,\”StartDate“:”2013年-10-01T00:00“,\"InitialSalary\":0,\"AccHolderName\":null,\"BankName\":\"brac\",\"Brunch\":\"uttra\",\"AccountNo\":1234567890,\"PositionDDLId\":0,\"MarriageStatDDLId\":0,\"PositionIdString\":\"Md\",\“MarriageIdString”:\“MarriageIdString\”:\“已婚\”}
我的JS文件负责使用jqGrid显示数据:
function allEmployeeFunc() {
$("#list").jqGrid({
url: "/Employee/AllEmployees",
datatype: "json",
mtype: "POST",
colNames: ["First name", "Last Name", "phone", "Mobile", "Email", "status"],
colModel: [
{ name: "FirstName", width: 55 },
{ name: "LastName", width: 90 },
{ name: "HomePhone", width: 80, align: "right" },
{ name: "MobileNo", width: 80, align: "right" },
{ name: "Email", width: 80, align: "right" },
{ name: "MarriageIdString", width: 150, sortable: false }
],
pager: "#pager",
rowNum: 10,
rowList: [10, 20, 30],
sortname: "invid",
sortorder: "desc",
viewrecords: true,
gridview: true,
autoencode: true,
caption: "Detail of all EMPLOYEE",
}); }
不幸的是,输出中没有数据,但是网格的内部是空的。有人能帮忙吗?
发布于 2014-11-06 17:47:01
你应该把线移开
var AllEmpObjects= JsonConvert.SerializeObject(employeesViewMod);,并将return Json(AllEmpObjects);替换为
return Json(employeesViewMod);https://stackoverflow.com/questions/26780431
复制相似问题