PDA

View Full Version : ExtJs Asynchronous Tree, Input from Java as JSON



sthanar
13 Aug 2013, 1:41 AM
Hi,

I want to make an Asynchronous tree in ext js 3.2.1 like as below
Parent
|-child1
|-child11
|-child12
|-child2
|-child3
|-child31.

I have data from the DB as follows.



ID
PARENT ID
NAME


5344
(null)
Qwest Washington


83688
5344
Anderson


83690
83688
Anderson_Const


83712
83688
Larson_Cable


83726
83712
SEAIR


83714
83688
Larson_Const


83748
83714
SECN2


83750
83714
SECN3


83692
5344
Butler


83694
83692
Cini_Const


83696
83692
Cini_Loop


83834
83696
TANW1


83836
83696
TANW2


83702
83692
Flores


83704
83702
Flores_Design


83730
83702
SEBG2


83732
83702
SEBG4


83734
83702
SEBG5



Data given above will change for each user. i want to write generic java method which construct tree and gives output as jsonString like below,

{id:'0',text:'Org Node',expanded: true, children:
[
{ id:'Org1', text: "node1", leaf: true },
{id:'Org2', text: "node2", expanded: true, children: [
{ id:'Org21', text: "node2-1", leaf: true },
{ id:'Org22', text: "node2-2", leaf: true }
]
},
{id:'Org3', text: "node3", leaf:true },
{id:'Org4', text: "node4", children: [
{ id:'Org41', text: "node4-1", leaf: true },
{ id:'Org42', text: "node4-2", leaf: true }
]
},
{id:'Org5', text: "node-5", leaf: true }
]
}

Please give me a generic concept to make tree.

slemmon
14 Aug 2013, 3:15 PM
You're looking for a server-script example of how to output the appropriate JSON from your database using Java?

Or you're looking for an ExtJS client example?

sthanar
15 Aug 2013, 10:12 PM
i am looking server script example. want to make appropriate JSON string from database using java.

slemmon
16 Aug 2013, 7:05 AM
I see. I'm not familiar with Java myself - I'll defer to the community.

**
That said, this is an ExtJS forum and you may ultimately find the question best answered in a Java forum where the focus of building JSON from a DB using Java is a question more commonly asked and answered.