PDA

View Full Version : setting proxy.reader.root for tree JSON with children



JackJohnsonX
27 Jan 2015, 5:04 PM
hello all,

my tree json format is similar to below json:


{
"text": ".",
"children": [
{
"task": "Project: Shopping",
"duration": 13.25,
"user": "Tommy Maintz",
"iconCls": "task-folder",
"expanded": true,
"children": [
{
"task": "Housewares",
"duration": 1.25,
"user": "Tommy Maintz",
"iconCls": "task-folder",
"children": [
{
"task": "Kitchen supplies",
"duration": 0.25,
"user": "Tommy Maintz",
"leaf": true,
"iconCls": "task"
}, {
"task": "Groceries",
"duration": .4,
"user": "Tommy Maintz",
"leaf": true,
"iconCls": "task",
"done": true
}, {
"task": "Cleaning supplies",
"duration": .4,
"user": "Tommy Maintz",
"leaf": true,
"iconCls": "task"
}, {
"task": "Office supplies",
"duration": .2,
"user": "Tommy Maintz",
"leaf": true,
"iconCls": "task"
}
]
}, {
"task": "Remodeling",
"duration": 12,
"user": "Tommy Maintz",
"iconCls": "task-folder",
"expanded": true,
"children": [
{
"task": "Retile kitchen",
"duration": 6.5,
"user": "Tommy Maintz",
"leaf": true,
"iconCls": "task"
}, {
"task": "Paint bedroom",
"duration": 2.75,
"user": "Tommy Maintz",
"iconCls": "task-folder",
"children": [
{
"task": "Ceiling",
"duration": 1.25,
"user": "Tommy Maintz",
"iconCls": "task",
"leaf": true
}, {
"task": "Walls",
"duration": 1.5,
"user": "Tommy Maintz",
"iconCls": "task",
"leaf": true
}
]
}, {
"task": "Decorate living room",
"duration": 2.75,
"user": "Tommy Maintz",
"leaf": true,
"iconCls": "task",
"done": true
}, {
"task": "Fix lights",
"duration": .75,
"user": "Tommy Maintz",
"leaf": true,
"iconCls": "task",
"done": true
}, {
"task": "Reattach screen door",
"duration": 2,
"user": "Tommy Maintz",
"leaf": true,
"iconCls": "task"
}
]
}
]
}, {
"task": "Project: Testing",
"duration": 2,
"user": "Core Team",
"iconCls": "task-folder",
"children": [
{
"task": "Mac OSX",
"duration": 0.75,
"user": "Tommy Maintz",
"iconCls": "task-folder",
"children": [
{
"task": "FireFox",
"duration": 0.25,
"user": "Tommy Maintz",
"iconCls": "task",
"leaf": true
}, {
"task": "Safari",
"duration": 0.25,
"user": "Tommy Maintz",
"iconCls": "task",
"leaf": true
}, {
"task": "Chrome",
"duration": 0.25,
"user": "Tommy Maintz",
"iconCls": "task",
"leaf": true
}
]
}, {
"task": "Windows",
"duration": 3.75,
"user": "Darrell Meyer",
"iconCls": "task-folder",
"children": [
{
"task": "FireFox",
"duration": 0.25,
"user": "Darrell Meyer",
"iconCls": "task",
"leaf": true
}, {
"task": "Safari",
"duration": 0.25,
"user": "Darrell Meyer",
"iconCls": "task",
"leaf": true
}, {
"task": "Chrome",
"duration": 0.25,
"user": "Darrell Meyer",
"iconCls": "task",
"leaf": true
}, {
"task": "Internet Explorer",
"duration": 3,
"user": "Darrell Meyer",
"iconCls": "task",
"leaf": true
}
]
}, {
"task": "Linux",
"duration": 0.5,
"user": "Aaron Conran",
"iconCls": "task-folder",
"children": [
{
"task": "FireFox",
"duration": 0.25,
"user": "Aaron Conran",
"iconCls": "task",
"leaf": true
}, {
"task": "Chrome",
"duration": 0.25,
"user": "Aaron Conran",
"iconCls": "task",
"leaf": true
}
]
}
]
}
]
}


what im trying to do is add a root at the top of the JSON. Again, im not talking about root node, but the treestore readers root. I guess the reader looks for "children" array.





{"mytreeroot":[
{
"text": ".",
"children": [
{
"task": "Project: Shopping",
"duration": 13.25,
"user": "Tommy Maintz",
"iconCls": "task-folder",
"expanded": true,
"children": [
{
"task": "Housewares",
"duration": 1.25,
"user": "Tommy Maintz",
"iconCls": "task-folder",
"children": [
{
"task": "Kitchen supplies",
"duration": 0.25,
"user": "Tommy Maintz",
"leaf": true,
"iconCls": "task"
}, {
"task": "Groceries",
"duration": .4,
"user": "Tommy Maintz",
"leaf": true,
"iconCls": "task",
"done": true
}, {
"task": "Cleaning supplies",
"duration": .4,
"user": "Tommy Maintz",
"leaf": true,
"iconCls": "task"
}, {
"task": "Office supplies",
"duration": .2,
"user": "Tommy Maintz",
"leaf": true,
"iconCls": "task"
}
]
}, {
"task": "Remodeling",
"duration": 12,
"user": "Tommy Maintz",
"iconCls": "task-folder",
"expanded": true,
"children": [
{
"task": "Retile kitchen",
"duration": 6.5,
"user": "Tommy Maintz",
"leaf": true,
"iconCls": "task"
}, {
"task": "Paint bedroom",
"duration": 2.75,
"user": "Tommy Maintz",
"iconCls": "task-folder",
"children": [
{
"task": "Ceiling",
"duration": 1.25,
"user": "Tommy Maintz",
"iconCls": "task",
"leaf": true
}, {
"task": "Walls",
"duration": 1.5,
"user": "Tommy Maintz",
"iconCls": "task",
"leaf": true
}
]
}, {
"task": "Decorate living room",
"duration": 2.75,
"user": "Tommy Maintz",
"leaf": true,
"iconCls": "task",
"done": true
}, {
"task": "Fix lights",
"duration": .75,
"user": "Tommy Maintz",
"leaf": true,
"iconCls": "task",
"done": true
}, {
"task": "Reattach screen door",
"duration": 2,
"user": "Tommy Maintz",
"leaf": true,
"iconCls": "task"
}
]
}
]
}, {
"task": "Project: Testing",
"duration": 2,
"user": "Core Team",
"iconCls": "task-folder",
"children": [
{
"task": "Mac OSX",
"duration": 0.75,
"user": "Tommy Maintz",
"iconCls": "task-folder",
"children": [
{
"task": "FireFox",
"duration": 0.25,
"user": "Tommy Maintz",
"iconCls": "task",
"leaf": true
}, {
"task": "Safari",
"duration": 0.25,
"user": "Tommy Maintz",
"iconCls": "task",
"leaf": true
}, {
"task": "Chrome",
"duration": 0.25,
"user": "Tommy Maintz",
"iconCls": "task",
"leaf": true
}
]
}, {
"task": "Windows",
"duration": 3.75,
"user": "Darrell Meyer",
"iconCls": "task-folder",
"children": [
{
"task": "FireFox",
"duration": 0.25,
"user": "Darrell Meyer",
"iconCls": "task",
"leaf": true
}, {
"task": "Safari",
"duration": 0.25,
"user": "Darrell Meyer",
"iconCls": "task",
"leaf": true
}, {
"task": "Chrome",
"duration": 0.25,
"user": "Darrell Meyer",
"iconCls": "task",
"leaf": true
}, {
"task": "Internet Explorer",
"duration": 3,
"user": "Darrell Meyer",
"iconCls": "task",
"leaf": true
}
]
}, {
"task": "Linux",
"duration": 0.5,
"user": "Aaron Conran",
"iconCls": "task-folder",
"children": [
{
"task": "FireFox",
"duration": 0.25,
"user": "Aaron Conran",
"iconCls": "task",
"leaf": true
}, {
"task": "Chrome",
"duration": 0.25,
"user": "Aaron Conran",
"iconCls": "task",
"leaf": true
}
]
}
]
}
]
}


the highlighted part above is what i need, especially because one response can contain data for numerous trees, thus i need to differentiate them with ROOTs. Also, if this can be formatted to remove the first object above

{"text":"", "children":[{}]}

without affecting the appearance of the tree, that will be great

Also, ive already defined tree root node in my treestore and set rootVisible:false

//store
.........
root:{
id:"0",
text:"",
expanded:false
}

lumberjack
29 Jan 2015, 5:53 AM
Your proxy reader's rootProperty config also accepts a function that receives the object and can then evaluate that data to return.

Regards,
Brian

gmv