jquery Easy UI 的datagrid的时候遇到问题了,大神们请帮忙看下
程序框架是用的asp.net的MVC
后台代码是这样子的
[HttpPost]
public ActionResult Index1()
{
StringBuilder strb=new StringBuilder();
strb.Append("{\"total\":126,\"rows\":[{\"address\":\"CZ88.NET \",\"city\":\"IANA保留地址\",\"id\":\"1\"},");
strb.Append("{\"address\":\"CZ88.NET \",\"city\":\"澳大利亚\",\"id\":\"2\"},");
strb.Append("{\"address\":\"电信\",\"city\":\"福建省\",\"id\":\"3\"},");
strb.Append("{\"address\":\"CZ88.NET \",\"city\":\"澳大利亚\",\"id\":\"4\"},");
strb.Append("{\"address\":\"CZ88.NET \",\"city\":\"泰国\",\"id\":\"5\"},");
strb.Append("{\"address\":\"CZ88.NET \",\"city\":\"日本\",\"id\":\"6\"},");
strb.Append("{\"address\":\"电信\",\"city\":\"广东省\",\"id\":\"7\"},");
strb.Append("{\"address\":\"CZ88.NET \",\"city\":\"日本\",\"id\":\"8\"}]}");
return Json(strb.ToString());
}
前台JS代码是这样的
<script>
function loder() {
$('#grid').datagrid({
title: '表格',
width: 700,
height: 500,
method:"post",
url: 'Home/Index1',
columns: [[{ field: 'ID', title: 'id', width: 100, align: 'center' },
{ field: '地区', title: 'city', width: 120, align: 'left' },
{ field: '地址', title: 'address', align: 'left', width: 500 }]]
});
}
</script>
页面代码:
<body>
<input type="button" id="updateGrid" onclick="loder()" value="更新标题"/>
<table id="grid"></table>
</body>
火狐里报错是这样的
TypeError: rows is undefined
火狐浏览器请求响应到的数据是这样的图片
响应的字符串
"{\"total\":126,\"rows\":[{\"address\":\"CZ88.NET \",\"city\":\"IANA保留地址\",\"id\":\"1\"},{\"address\":\"CZ88.NET \",\"city\":\"澳大利亚\",\"id\":\"2\"},{\"address\":\"电信\",\"city\":\"福建省\",\"id\":\"3\"},{\"address\":\"CZ88.NET \",\"city\":\"澳大利亚\",\"id\":\"4\"},{\"address\":\"CZ88.NET \",\"city\":\"泰国\",\"id\":\"5\"},{\"address\":\"CZ88.NET \",\"city\":\"日本\",\"id\":\"6\"},{\"address\":\"电信\",\"city\":\"广东省\",\"id\":\"7\"},{\"address\":\"CZ88.NET \",\"city\":\"日本\",\"id\":\"8\"}]}"
页面上显示的datagrid