PDA

View Full Version : Preparing data for tree grid from the List<>.



bevara.siva
10 Jul 2014, 11:04 PM
Hi,

We are using ExtJS 4.2.2

I get List<Employees> data in the service. I need to use this to populate the tree grid. I can be able to populate the normal grid by sending the corresponding json to the client from the WCF service.

I need the same data to populate a tree grid. How can I add the Child:[] to the lists and add the child records into that.

Please help!!!

Regards,
SivaPrasad.B

mitchellsimoens
16 Jul 2014, 10:59 AM
Is the data in a tree format or are you just wanting to add an array of items to some existing node in the tree?

bevara.siva
16 Jul 2014, 11:32 PM
Thank you for the response.
In my case, I get an XML file and need to make that to load the tree.
As of now I am able to return the data as JSON objects from the service as below.


{"GetPositionSummaryResult":
[{Client:"Mars","MValue":2700000,"LT":"","Price":null,"Quantity":null,"Type":""},
{Client:"ADR","MValue":2700000,"LT":"","Price":null,"Quantity":null,"Type":""},
{Client:"US Bonds","MValue":2700000,"LT":"","Price":null,"Quantity":null,"Type":""},
{Client:"States","MValue":2700000,"LT":"","Price":null,"Quantity":null,"Type":""},
{Client:"GMB","MValue":2700000,"LT":"Ba1","Price":100,"Quantity":27000,"Type":"GM"}]}


It is displaying the tree as normal grid as below.
49688


But I need the data as below:



{
expanded: true,
children: [
{ Client:"Mars",MValue:2700000,LT:"",Price:null,Quantity:null,Type:"", expanded:true,
children:[
{ Client:"ADR",MValue:2700000,LT:"",Price:null,Quantity:null,Type:"", expanded:true,
children:[
{ Client:"US Bonds",MValue:2700000,LT:"",Price:null,Quantity:null,Type:"", expanded:true,
children:[
{ Client:"States",MValue:2700000,LT:"",Price:null,Quantity:null,Type:"", expanded:true,
children:[
{ Client:"GMB",MValue:2700000,LT:"Ba1",Price:100,Quantity:27000,Type:"GM", leaf:true}
]
}]
}]
}]
}]
}



So that it can show the tree grid as below.
49689


Please help.

Regards,
SivaPrasad.B