树的循环遍历与递归拼接

def Loadtree(id):
	root={"title": "main","key":0,"children": ""}
	root["children"]=bindchildnode(0)
	return root


def bindchildnode(did):	
	nodechild=[]
	treeList=Functionmodule.objects.filter(parentid=did)	
	if treeList.count()>0:			
		for tree in treeList:
			nodechild.append({"title": tree.modulename,"key":tree.id,"children":bindchildnode(tree.id)})
	return nodechild

你可能感兴趣的:(树的循环遍历与递归拼接)