easyUI datagrid一直不出数据

偷垃圾的猫 偷垃圾的猫 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
如题,我感觉我的代码是正确的,可是一直不出数据。看了好多帖子,试了各种办法,都没用,我快要崩溃了。请各位帮帮忙
我的前台代码:
<div id="dd"></div>

$(function () {
$('#dd').datagrid({
title: "测试 ",
width: "auto",
striped: true,
singleSelect: true,
loadMsg: "正在加载,请稍等...",
url: '/test/GetGridData', //获取数据地址
pagination: true,
rownumbers: true,
pageList: [5, 10, 15, 20],
pageSize: 10,
idField: "id",
columns: [[
{ title: "测试1", field: "productid", width: "180", align: "center" },
{ title: "测试2", field: "productname", width: "300", align: "center" },
{ title: "测试3", field: "city", width: "300", align: "center" }
]]
});
});
后台代码:
public JsonResult GetGridData(int rows, int page)
{

//result为json数据格式测试
string result = "";
result += "{\"total\":" + (rows *page)+ " ";
result += "rows:{[ ";
for (int i = 0; i <= rows; i++)
{
result += "{\"productid\":编号" + i + ",\"productname\":姓名" + i + ",\"city\":城市" + i + "\"}";
}
result += "]}";

JsonResult js = Json(result, JsonRequestBehavior.AllowGet);
return js;
}
...全文
评论 46
收藏 已收藏
分享
返回顶部
偷垃圾的猫
JavaScript 87,984 成员 224,681 内容