<!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"}]}
请问为什么数据显示不出来?
你的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"}]}
我是用.net的json类获取的,json格式应该是我前面发的那种,那我现在还得进行一次字符串拼接才能正常吗?那效率好低
@何小飞: net中很容易加上这个的。你重写下.net的json类方便些吧。
可以用json.net
好的,谢谢