求大神放慢脚步,如何在jsp页面接受并处理后台传过来的json生成一个treegrid这种类型的树啊?Help!!! 50
我后台封装的json类型是:[{"id":1,"name":"中国","parentName":"","parentid":0},{"id":2,"name":"江苏",...
我后台封装的json类型是:
[{"id":1,"name":"中国","parentName":"","parentid":0},
{"id":2,"name":"江苏","parentName":"中国","parentid":1},
{"id":3,"name":"北京","parentName":"中国","parentid":1},
{"id":4,"name":"南京","parentName":"江苏","parentid":2},
{"id":5,"name":"朝阳区 ","parentName":"北京","parentid":3},
{"id":6,"name":"昌平","parentName":"北京","parentid":3},
{"id":7,"name":"无锡","parentName":"江苏","parentid":2},
{"id":8,"name":"北七家镇","parentName":"昌平","parentid":6}]
jsp页面如何使用treegrid这个东西来解析生成一个表格树(必须是treegrid类型的树,不是datagrid类型的树)
我的这个一定写错了,该怎么修改才能获得后台传过来的数据并解析? 展开
[{"id":1,"name":"中国","parentName":"","parentid":0},
{"id":2,"name":"江苏","parentName":"中国","parentid":1},
{"id":3,"name":"北京","parentName":"中国","parentid":1},
{"id":4,"name":"南京","parentName":"江苏","parentid":2},
{"id":5,"name":"朝阳区 ","parentName":"北京","parentid":3},
{"id":6,"name":"昌平","parentName":"北京","parentid":3},
{"id":7,"name":"无锡","parentName":"江苏","parentid":2},
{"id":8,"name":"北七家镇","parentName":"昌平","parentid":6}]
jsp页面如何使用treegrid这个东西来解析生成一个表格树(必须是treegrid类型的树,不是datagrid类型的树)
我的这个一定写错了,该怎么修改才能获得后台传过来的数据并解析? 展开
4个回答
展开全部
我没有用过这个, 说说我的看法, 看看可行不:
frozenColumns:[[
{
title: '国家',
field: 'id',
width: 200,
....
}
]]
我认为这段代码是定义国家的, 那在后台取数据的时候, 把所有的国家都取出来然后按照以上格式封装, 比如你的第一条数据:
{"id":1,"name":"中国","parentName":"","parentid":0} 可以封装为:
{"title": '中国', field: 1, width: 200, ...} // 省略号自己补充
// 如果有多个国家就可以封装成这样了:
[
{"title": '中国', field: 1, width: 200, ...},
{"title": '美国', field: 2, width: 200, ...},
{"title": '英国', field: 3, width: 200, ...}
}
// 这样的格式是不是就可以直接放到 frozenColumns:[] 里边了呢!
同样的道理处理下面的columns:[]; 不知道可以明白吗?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
虽然我不太了解你用的这个控件,但是道理应该是一样的,id和parentid的关系,要让你的控件知道
更多追问追答
追问
我要是知道如何让控件知道两者的关系,我就不会发问了!就是不知道如何写easyui treegrid这个部分
追答
[{
"id":1,
"name":"C",
"size":"",
"date":"02/19/2010",
"children":[{
"id":2,
"name":"Program Files",
"size":"120 MB",
"date":"03/20/2010",
"children":[{
"id":21,
"name":"Java",
"size":"",
"date":"01/13/2010",
"state":"closed",
"children":[{
"id":211,
"name":"java.exe",
"size":"142 KB",
"date":"01/13/2010"
},{
"id":212,
"name":"jawt.dll",
"size":"5 KB",
"date":"01/13/2010"
}]
},{
"id":22,
"name":"MySQL",
"size":"",
"date":"01/13/2010",
"state":"closed",
"children":[{
"id":221,
"name":"my.ini",
"size":"10 KB",
"date":"02/26/2009"
},{
"id":222,
"name":"my-huge.ini",
"size":"5 KB",
"date":"02/26/2009"
},{
"id":223,
"name":"my-large.ini",
"size":"5 KB",
"date":"02/26/2009"
}]
}]
},{
"id":3,
"name":"eclipse",
"size":"",
"date":"01/20/2010",
"children":[{
"id":31,
"name":"eclipse.exe",
"size":"56 KB",
"date":"05/19/2009"
},{
"id":32,
"name":"eclipse.ini",
"size":"1 KB",
"date":"04/20/2010"
},{
"id":33,
"name":"notice.html",
"size":"7 KB",
"date":"03/17/2005"
}]
}]
}]
这是数据格式,如果需要我这里有刚下载的例子
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用easyUI jquery插件,很简单就可以了!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2014-01-22
展开全部
导入ui就行了,json格式直接放进去就自动转换了,我现在用的是zTree。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询