-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I have a ZUL file in which I have follwoing code-----
redraw = { page ->
def c1=ClientMap.executeQuery("select name from ClientMap where nodeType='0'")
def random = new java.util.Random(System.currentTimeMillis());
def r1 = new java.util.Random(random.nextInt())
treeClient.clear()
childChildren.append{
c1.each { e ->
treeitem(value:r1.nextInt(c1.size())){
treerow{
treecell(label: e.toString()){
}
}// treerow
if (e.toString()=="HOSPITAL"){
def c2=ClientMap.executeQuery("select name from ClientMap where nodeType='1'")
childChildren.append{
c2.each { f ->
treeitem(value:r1.nextInt(c2.size())){
treerow{
treecell(label: f.toString())
}
}
}
}
}//if ends HOSP
if (e.toString()=="CLINIC"){
def c3=ClientMap.executeQuery("select name from ClientMap where nodeType='2'")
childChildren.append{
c3.each { f ->
treeitem(value:r1.nextInt(c3.size())){
treerow{
treecell(label: f.toString())
}
}
}
}
}//if ends CLINIC
if (e.toString()=="LAB"){
def c4=ClientMap.executeQuery("select name from ClientMap where nodeType='3'")
childChildren.append{
c4.each { f ->
treeitem(value:r1.nextInt(c4.size())){
treerow{
treecell(label: f.toString())
}
}
}
}
}//if ends CLINIC
}//treeitem c1 for
}//c1.each
}// end of childappend
}
==========================================
The BootStrap.groovy has following code===
def Client1 = new ClientMap(name:'HOSPITAL',nodeType:'0').save()
def Client2 = new ClientMap(name:'CLINIC',nodeType:'0').save()
def Client3 = new ClientMap(name:'LAB',nodeType:'0').save()
def Client4 = new ClientMap(name:'HOSPITAL1',nodeType:'1').save()
def Client5 = new ClientMap(name:'HOSPITAL2',nodeType:'1').save()
def Client6 = new ClientMap(name:'CLINIC1',nodeType:'2').save()
def Client7 = new ClientMap(name:'CLINIC2',nodeType:'2').save()
def Client8 = new ClientMap(name:'LAB1',nodeType:'3').save()
def Client9 = new ClientMap(name:'LAB2',nodeType:'3').save()
==========================================================
and ClientMap.groovy file has following code --------
class ClientMap {
String name
Integer nodeType
static constraints = {
name(blank: false)
nodeType(blank: false)
}
}
=====================================================================
I get treee structure as follows===
Hospital
Hospital1
Hospital2
Clinic
Clinic1
Clinic2
Lab
Lab1
Lab2
How can make "HOSPITAL1" child of HOSPITAL and "HOSPITAL2" child of HOSPITAL1 and so on..
To make the above tree look like ==
Hospital
- Hospital1
-Hospital2
Clinic
- Clinic1
-Clinic2
Lab
-Lab1
-Lab2
Asked: 2009-10-12 11:22:12 +0800
Seen: 126 times
Last updated: Oct 14 '09