日期:2014-05-16  浏览次数:20461 次

请问如何构建ext树的json数据?
String sql = "select cc_h as id ,cc_mc as text from cc ";
List list =getSqlList(sql);
JSONArray jsonObject = JSONArray.fromObject(list);
json = jsonObject.toString();

出来的数据是
[{"text":"aa","id":"2"},{"text":"bb","id":"3"},{"text":"cc","id":"4"},
{"text":"dd","id":"5"}]


都只是根的子节点,没有根据 cc 的parent_cc_h 构建子节点

------解决方案--------------------
JScript code

var tree = new Ext.tree.TreePanel({
        loader: new Ext.tree.TreeLoader({
            dataUrl: '10-01.txt'
        }),
        root: new Ext.tree.AsyncTreeNode({
            id: '0',
            text: '根'
        }),
        autoHeight: true,
        renderTo: 'tree'
    });

------解决方案--------------------
如何生成Ext树所需的json字符串