怎么把后台查出来的json字符串转换成jquery easyui combotree需要的json格式
推荐于2018-07-06 · 知道合伙人软件行家
关注
展开全部
jquery easyui之tree控件的数据格式化有如下属性:
id:节点ID,对加载远程数据很重要
text:显示节点文本
state:节点状态,'open' 或 'closed',默认:'open'。如果为'closed'的时候,将不自动展开该节点
checked:表示该节点是否被选中
attributes: 被添加到节点的自定义属性
children: 一个节点数组声明了若干节点
示例:
[{
"id":1,
"text":"Folder1",
"iconCls":"icon-save",
"children":[{
"text":"File1",
"checked":true
},{
"text":"Books",
"state":"open",
"attributes":{
"url":"/demo/book/abc",
"price":100
},
"children":[{
"text":"PhotoShop",
"checked":true
},{
"id": 8,
"text":"Sub Bookds",
"state":"closed"
}]
}]
},{
"text":"Languages",
"state":"closed",
"children":[{
"text":"Java"
},{
"text":"C#"
}]
}]
展开全部
直接在后台拼写成combotree能识别的json字符串
追问
怎么拼写?本人刚刚接触这些东西 ,求举个详细的例子 (后台查询出来的是一个List)
追答
如果是list可以用JSONArray a =JSONArray.fromObject(list);进行转换
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
var data ='[{"text":"事故损失类","state":"closed","Ucode":"0002","Pcode":"-1","Ulevel":"1","id":"1","children":[{"text":"车损附件","state":null,"Ucode":"0003","Pcode":"0002","Ulevel":"2","id":"11","children":[{"text":"车辆正面45度","state":null,"Ucode":"0004","Pcode":"0003","Ulevel":"3","id":"111","children":null},{"text":"车辆尾部45度","state":null,"Ucode":"0005","Pcode":"0003","Ulevel":"3","id":"112","children":null}]},{"text":"货物损失","state":null,"Ucode":"0006","Pcode":"0002","Ulevel":"2","id":"12","children":[{"text":"车辆正面45度","state":null,"Ucode":"0007","Pcode":"0006","Ulevel":"3","id":"121","children":null}]}]},{"text":"车损附件","state":null,"Ucode":"0003","Pcode":"0002","Ulevel":"2","id":"11","children":[{"text":"车辆正面45度","state":null,"Ucode":"0004","Pcode":"0003","Ulevel":"3","id":"111","children":null},{"text":"车辆尾部45度","state":null,"Ucode":"0005","Pcode":"0003","Ulevel":"3","id":"112","children":null}]},{"text":"货物损失","state":null,"Ucode":"0006","Pcode":"0002","Ulevel":"2","id":"12","children":[{"text":"车辆正面45度","state":null,"Ucode":"0007","Pcode":"0006","Ulevel":"3","id":"121","children":null}]}]';
var k= JSON.parse(data);
$("#cc").combotree('loadData',k);
重要的是要把json字符串序列化
var k= JSON.parse(data);
$("#cc").combotree('loadData',k);
重要的是要把json字符串序列化
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询