easyUI datagrid一直不出数据
如题,我感觉我的代码是正确的,可是一直不出数据。看了好多帖子,试了各种办法,都没用,我快要崩溃了。请各位帮帮忙
我的前台代码:
<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;
}
我的前台代码:
<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;
}
...全文
相关推荐
easyui datagrid 数据导出到Excel
获取datagrid数据:通过EasyUI Datagrid的API,如`$("#datagridId").datagrid("getData")`获取到数据对象。3.
JS EasyUI DataGrid动态加载数据
JS EasyUI DataGrid是一款基于jQuery和EasyUI框架的数据表格组件,它提供了丰富的功能,如数据分页、排序、过滤和自定义操作等。
EasyUI的DataGrid每行数据添加操作按钮的实现代码
在使用EasyUI开发Web应用程序时,DataGrid是一个非常实用的组件,它可以帮助我们展示大量结构化的数据,并且提供了丰富的交互功能。
EasyUI可扩展Editable DataGrid(可编辑数据表格)
DataGrid是EasyUI中的核心组件之一,用于展示和管理大量结构化的数据。
easyui datagrid 表格 打印
总的来说,要实现EasyUI Datagrid表格的打印,关键在于处理好格式化数据的转换和打印样式的一致性。


