怎么把后台查出来的json字符串转换成jquery easyui combotree需要的json格式

 我来答
青鸟中关村专家
推荐于2018-07-06 · 知道合伙人软件行家
青鸟中关村专家
知道合伙人软件行家
采纳数:1734 获赞数:8440
就职于北大青鸟中关村,自2004年踏入北大青鸟这个行业,已经有11年工作经验和8年的培训经验,寓教于乐

向TA提问 私信TA
展开全部

jquery easyui之tree控件的数据格式化有如下属性:

  1. id:节点ID,对加载远程数据很重要

  2. text:显示节点文本

  3. state:节点状态,'open' 或 'closed',默认:'open'。如果为'closed'的时候,将不自动展开该节点

  4. checked:表示该节点是否被选中

  5. attributes: 被添加到节点的自定义属性

  6. 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#"   
    }]    
}]
搜哈KK
2012-09-05 · 超过18用户采纳过TA的回答
知道答主
回答量:59
采纳率:0%
帮助的人:43.1万
展开全部
直接在后台拼写成combotree能识别的json字符串
追问
怎么拼写?本人刚刚接触这些东西 ,求举个详细的例子 (后台查询出来的是一个List)
追答
如果是list可以用JSONArray a =JSONArray.fromObject(list);进行转换
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
鹏蓬88
2018-07-06 · TA获得超过439个赞
知道答主
回答量:133
采纳率:73%
帮助的人:17.3万
展开全部
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字符串序列化
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式