我的键/父结构如下:
[Object { parent="0", key="5961"}, Object { parent="5961", key="5960"}, Object { parent="5960", key="5826"}, Object { parent="5826", key="5841"}, Object { parent="5841", key="5915"}]
Root对象是parent =“0”所有其他都是子对象,并且这样解决:
$.each (data, function(index,value){
key += "/" + value.key;
});
当我有更多的根对象并且需要拥有第一个根然后所有的孩子......第二个根然后是所有孩子等等时,问题就开始了......这是有问题的对象:
[Object { parent="0", key="5961"}, Object { parent="0", key="5962"}, Object { parent="5961", key="5960"}, Object { parent="5824", key="2237"}, Object { parent="5962", key="5824"}, Object { parent="5960", key="5826"}, Object { parent="2237", key="5834"}, Object { parent="2237", key="5838"}, Object { parent="5826", key="5841"}, Object { parent="2237", key="5843"}, Object { parent="5865", key="5846"}, Object { parent="5865", key="5862"}, Object { parent="5838", key="5865"}, Object { parent="5843", key="5874"}, Object { parent="5834", key="5894"}, Object { parent="5865", key="5912"}, Object { parent="5841", key="5915"}, Object { parent="5865", key="5935"}]
你可以看到两个root parent =“0”。可以有两个以上的根节点。
感谢。