PDA

View Full Version : TreeStore with varying root properties



demami
6 Sep 2013, 2:12 PM
I'm loading a TreeStore (from a REST service via an AJAX proxy) using JSON looking like this:



{
"Name": "Maps",
"Maps": [
{
"MapID": 8,
"MapInstances": [
{
"MapInstanceID": 5,
"MapID": 8,
"Name": "TestMap1",
"MapTypeID": -1,
"leaf": true
}
],
"Name": "TestMap",
},
{
"MapID": 9,
"MapInstances": [
{
"MapInstanceID": 6,
"MapID": 9,
"Name": "TestMap1",
"MapTypeID": -1,
"leaf": true
}
],
"Name": "TestMap",
}
]
}


My problem is, the root property is different at different levels of the tree. At the first node, it's Maps. At the second level, it's MapInstances. How do I set the reader's root property so that I will get:

Maps
>Map
>>Map Instance
>Map
>>Map Instance

?

Looking at the docs, I don't see an event I can hook to intercept finding the root property for a given node. I suppose I could load the JSON manually and use setRoot, but I'd rather avoid this if possible. Any suggestions?

ettavolt
8 Sep 2013, 11:53 PM
Unfortunately, you will need to create tree completely yourself. Or extend tree-related classes.