Dojo 0.9 Tree, Json, DnD .. Sample Code too much to hope for ? :)

Hey everyone,

Okay, apparently, I am a complete moron, and I am 'okay' with that. I am a de-constructive learner, I learn by tearing things apart and re-building ;) I have got most of the other stuff working fine (validation text boxes, date selectors, etc) under dojo+django. However, the clincher is that the Tree code in 0.9 is .. strange. I grasp the concept of a data store but, when I point it to a JSON url, nothing happens. No node's displayed, updated, etc.

in my html body I have ;

<div dojoType="dojo.data.ItemFileReadStore" jsId="popStore" url="/data/tstjson/"></div>
<div dojoType="dijit.Tree" id="mytree" store="popStore" labelAttr="name"></div>

and I get the following back from the url /data/tstjson/

[{'id': "1", 'text': "Public", 'leaf': "false", 'qtip': "blah", 'qtipTitle': "foo", 'cls': "folder","children":[{'id': "1", 'text': "fred hoskins", 'leaf': "true", 'qtip': "blah", 'qtipTitle': "foo", 'cls': "folder"}]},{'id': "2", 'text': "Private", 'leaf': "false", 'qtip': "blah", 'qtipTitle': "foo", 'cls': "folder","children":[{'id': "1", 'text': "fred hoskins", 'leaf': "true", 'qtip': "blah", 'qtipTitle': "foo", 'cls': "folder"}]},{'id': "3", 'text': "Work", 'leaf': "false", 'qtip': "blah", 'qtipTitle': "foo", 'cls': "folder","children":[{'id': "1", 'text': "fred hoskins", 'leaf': "true", 'qtip': "blah", 'qtipTitle': "foo", 'cls': "folder"}]}]

obviously, you get the idea. 3 categories (okay, with the same person, I know, but, you get the idea hopefully). I have tried with a different id in the children (eg; 11, 22, 33, etc) without any luck either. The dojo environment is all loaded up (I am using the other dojo stuff without trouble).

 

I also get the feeling reading around that I am not the only one who is having problems, so, does anyone have a -nice- -simple- example of programatically loading a tree using JSON ?

As I said, if I am missing something obvious, feel free to smack me upside the head.

Thanx,

Fraunhoffer

Comments

Tree + Json example

Hi Fraunhoffer,
I've put together a simple (imo) example that should be transferable to your program. You can find the demo at:

http://www.dojoforum.com/demo-0.9/tree.html

and it's grabbing information from a PHP script that's located at:

http://www.dojoforum.com/demo-0.9/tree_loader.php

Most of it should be self-explanatory if you've already worked a bit w/ Dojo, but feel free to ask me questions if something isn't clear.
Thanks,
achillean

DND example?

You example was very helpful. I was able to get my tree working.

Would you happen to have a drag-n-drop example using a tree and a container other than another tree?

Thanks,
Steven Brixie

Back to top