Is there any way to tell the TreePanel what format the json data is coming back in? I.E. I am querying from a server in which I do not have control over so I would like to somehow 'map' the properties that are coming back from the server to property names that the TreePanel will understand. Actually it is probably the TreeLoader that needs the 'mapping'

But what if the server I am requesting data from is returning the entire tree in json but not with those object names:

simple example with some of the property names changed here is the mapping I would like to apply for this example:
name -> text (i.e I am getting back name, but TreePanel wants text property)
moredata -> children (again in this bad example I am getting moredata for the children array property, need to map it to children)

This is all very new to me and reading the examples and the documentation I am not really sure if there is a way to do this mapping, but I would like to know for sure before I do it the hard way.

I looked into extending TreeLoader to look for a different format but I am not sure that is really possible. Please help.

Thanks!

forumuser1080

24 Feb 2011, 6:01 PM

Still trying to figure out if I can extend TreeLoader and override some functionality to parse json data that is not coming back exactly like TreeLoader is expected. If anyone has been able to do this please help as I have not yet found a way.

Thanks

drian

24 Feb 2011, 11:52 PM

I think the only way is to get the response from the server with "text" and "children". These are actually "configs" so you need to respect the names.

From your server you can send more data bound to 1 node, and you can easily access them as yourNode.attributes['extraDataNameHere']. So, proccess your data on the server, send "text" and "children", and if you really need to have an attribute named "name" and "moredata', you can add them as well.(but i doubt you really need them)

Condor

25 Feb 2011, 12:02 AM

Override the createNode method of the TreeLoader (or for more complex data override processResponse - but you don't need that).

forumuser1080

25 Feb 2011, 8:59 AM

Thanks for the responses guys. I am more confused now than ever.

drian,
I am not sure exactly how to configure my server to send more data bound to one node. I am also not really sure what that means. I don't really want to send children: [...], and moredata[...] which are really the same thing as it seems like overkill to send the same data and will slow down my response.

Condor,
Looking at createNode I don't see where it is accessing the children attribute. I would need to change something to say, hey don't look for an object named children look for an object named moredata. Maybe this is possible in the createNode but being a newbie I cannot figure it out.

Thanks so much for the help so far and if you have any other ideas please let me know.