jQuery ztree实现动态树形多选菜单(2)

public List<Inner> getTrees(){ Inner in=new Inner(); in.setId(1); in.setpId(0); in.setIsParent("true"); in.setName("父节点1"); Inner in1=new Inner(); in1.setId(2); in1.setpId(1); in1.setName("子节点11"); in1.setIsParent("true"); Inner in2=new Inner(); in2.setId(3); in2.setpId(1); in2.setName("子节点12"); Inner in3=new Inner(); in3.setId(4); in3.setpId(2); in3.setName("子节点111"); Inner in4=new Inner(); in4.setId(5); in4.setpId(0); in4.setIsParent("true"); in4.setName("父节点2"); Inner in5=new Inner(); in5.setId(6); in5.setpId(5); in5.setName("子节点21"); List<Inner> list=new ArrayList<Inner>(); list.add(in); list.add(in1); list.add(in2); list.add(in3); list.add(in4); list.add(in5); return list; } public Inner getById(Integer id){ List<Inner> list = getTrees(); for (Inner inner : list) { if(id==inner.getId()){ Inner in=inner; return in; } } return null; } public List<Inner> getChilds(Integer id){ List<Inner> list = getTrees(); List<Inner> result =new ArrayList<OmRequestImpl.Inner>(); for (Inner inner : list) { if(id.intValue()==inner.getpId().intValue()){ result.add(inner); } } return result; }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wzxwjs.html