jquery的treegrid不显示数据,JSON有值

我要做一个treegrid来显示数据,后台传过来的json里面有值,就是前台不展示出来,这是什么原因。前台代码是:<tableid="tt"fit="true"name=... 我要做一个treegrid来显示数据,后台传过来的json里面有值,就是前台不展示出来,这是什么原因。

前台代码是:
<table id="tt" fit="true" name="tt"
title="站点文章数统计列表" singleSelect="true" rownumbers="true"
idField="friendshipId" >
</table>
$('#tt').treegrid({
title:'TreeGrid',
iconCls:'icon-save',
url:"${ctx}/admin/site/lw-transit!articelsTotal.action",
width:700,
height:350,
nowrap: false,
rownumbers: true,
animate:true,
collapsible:true,
idField:'code',
treeField:'code',
pagination : true,
pageSize : 10,
columns:[[
{field:'channelId',title:'channelId',width:250},
{field:'name',title:'栏目',width:250},
{field:'allNumber',title:'总文章数',width:60,align:'center',sortable:true},
{field:'publishNumber',title:'已发布数',width:60,align:'center',sortable:true},
{field:'visitNumber',title:'文章访问量',width:60,align:'center',sortable:true}
]]
});
从浏览器获得的JSON是:
{"total":116,"rows":[
{"channelId":"40288116362010420136202661da0012","name":"新闻","publishNumber":"21","allNumber":"34","visitNumber":"0"},
{"channelId":"402881283628a1750136290debc3010f","name":"常识","publishNumber":"12","allNumber":"12","visitNumber":"0"},
{"channelId":"402881163615450801361550c29c0078","name":"规范建设","publishNumber":"3","allNumber":"3","visitNumber":"0"},
{"channelId":"40288116361545080136155063e30071","name":"管理创新","publishNumber":"10","allNumber":"10","visitNumber":"0"},
{"channelId":"402881283629b147013629cc08d700ce","name":"其他规定","publishNumber":"5","allNumber":"5","visitNumber":"0"},
{"channelId":"402881283629b147013629e816e801b0","name":"应急预案","publishNumber":"6","allNumber":"6","visitNumber":"0"},
{"channelId":"402881283629b147013629bb76dd0073","name":"领导信息","publishNumber":"1","allNumber":"1","visitNumber":"0"},
{"channelId":"4028812836295f340136297684c10016","name":"工作动态","publishNumber":"10","allNumber":"10","visitNumber":"0"},
{"channelId":"4028812836295f34013629753fec0008","name":"业务办理","publishNumber":"21","allNumber":"21","visitNumber":"0"},
{"channelId":"402881283629b147013629df077a0148","name":"综合管理","publishNumber":"19","allNumber":"19","visitNumber":"0"}]}
展开
 我来答
wangzhiyonglyk
2012-07-13 · TA获得超过184个赞
知道答主
回答量:125
采纳率:100%
帮助的人:92.3万
展开全部
因为你的json格式数据中没有code这个字段。treeField属性是设置树的图标出现在哪个列中。idField属性是设置json格式数据的关键字段。在你这个返回的json格式数据中你可以把treeField:"name",而idField:"channelId "。 另外要形成树的结构必须有在返回的json格式数据中必须有_parentId这个字段(这个必须是这样_parentId),关联到你所指定的idField。这样才找到父子关系。

另外有treegrid不能分页。如果你想分页最好用datagrid.分页会传四个参数给后台。
追问
搞定了,确实是JSON格式有误,再加上引入的JS版本也不对,所以不显示数据。再问一下,关于JSON,是否需要按照父结点、子结点进行排序?如果返回的JSON中,子结点在父结点之前,是否能够正常显示数据?
追答
能够,只要几个关键的字段设置正确就行了。 排序你可以在后台就排序好。
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式