首页 新闻 搜索 专区 学院

请救jquery easyui datagrid控件的问题

0
悬赏园豆:100 [已解决问题] 解决于 2011-12-25 16:22
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>jQuery EasyUI</title>
<link rel="stylesheet" type="text/css" href="themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="themes/icon.css">
<script type="text/javascript" src="jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="jquery.easyui.min.js"></script>
<script>
$(
function()
{
$(
'#tt').datagrid();
}
);
</script>
</head>
<body>
<table id="tt"
title
="用户信息一览"
url
="2.json">
<thead>
<tr>
<th field="date" width="180" editor="numberbox">日期</th>
<th field="sum" width="150" editor="text">合计金额</th>
</tr>
</thead>
</table>
</body>
</html>


前台代码

获取到的json数据

{[{"date":"2011/9/26 0:00:00","sum":"27.00"},{"date":"2011/9/27 0:00:00","sum":"34.00"},{"date":"2011/9/28 0:00:00","sum":"155.00"},{"date":"2011/9/29 0:00:00","sum":"26.00"},{"date":"2011/9/30 0:00:00","sum":"23.00"},{"date":"2011/10/1 0:00:00","sum":"24.00"},{"date":"2011/10/2 0:00:00","sum":"93.00"},{"date":"2011/10/3 0:00:00","sum":"33.50"},{"date":"2011/10/4 0:00:00","sum":"23.00"},{"date":"2011/12/19 0:00:00","sum":"12.00"}]}

 

请问为什么数据显示不出来?

何小飞的主页 何小飞 | 初学一级 | 园豆:29
提问于:2011-12-24 01:46
< >
分享
最佳答案
0

你的json格式不正确,要求前面有个"rows":的,如下所示

{"rows":[{"date":"2011/9/26 0:00:00","sum":"27.00"},{"date":"2011/9/27 0:00:00","sum":"34.00"},{"date":"2011/9/28 0:00:00","sum":"155.00"},{"date":"2011/9/29 0:00:00","sum":"26.00"},{"date":"2011/9/30 0:00:00","sum":"23.00"},{"date":"2011/10/1 0:00:00","sum":"24.00"},{"date":"2011/10/2 0:00:00","sum":"93.00"},{"date":"2011/10/3 0:00:00","sum":"33.50"},{"date":"2011/10/4 0:00:00","sum":"23.00"},{"date":"2011/12/19 0:00:00","sum":"12.00"}]}
收获园豆:100
LCM | 大侠五级 |园豆:6876 | 2011-12-24 10:44

我是用.net的json类获取的,json格式应该是我前面发的那种,那我现在还得进行一次字符串拼接才能正常吗?那效率好低

何小飞 | 园豆:29 (初学一级) | 2011-12-24 11:07

@何小飞: net中很容易加上这个的。你重写下.net的json类方便些吧。

LCM | 园豆:6876 (大侠五级) | 2011-12-24 11:57
其他回答(1)
0

可以用json.net

万里沙来手一挥 | 园豆:196 (初学一级) | 2011-12-25 11:10

好的,谢谢

支持(0) 反对(0) 何小飞 | 园豆:29 (初学一级) | 2011-12-25 16:21
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册