[Dojo-interest] dijit.Tree and dojox.data.JsonRestStore

Rice Yeh riceyeh at gmail.com
Mon Dec 28 10:58:12 EST 2009


Hi,
  After studying the source code of TreeModelStore, I find this problem is
caused by a bug in TreeModelStore.getChildren method. With addition of 2
lines and chane of 1 line in the code, it works now. The following is my
change: (The version I am using 1.4.0)

line 158 (added)>                var children = [];
                      // still waiting for some or all of the items to load
                var onItem = function onItem(item){
added>                    dojo.forEach(item, function(n) { children.push(n)
});
                    if(--_waitCount == 0){
                        // all nodes have been loaded, send them to the tree
changed>                        onComplete(children);
                    }
                }

Regards,
Rice

On Mon, Dec 28, 2009 at 10:14 PM, Rice Yeh <riceyeh at gmail.com> wrote:

> Hi,
>   I use dijit.Tree associated with dojox.data.JsonRestStore with html
> markup. The root of the tree is successfully rendered with the fetched json:
>
> [
>     {
>         "class": "xs.personnel.Organization",
>         "name": "ILF International",
>         "oid": 2,
>         "type": "company",
>         "children": {
>             "$ref": "http://localhost:8080/personnel/bureaucracy/object/2/children"
>         }
>     }
> ]
>
> Then, I click on the root node, its children are fected as shown below:
>
> [
>     {
>         "class": "xs.personnel.Organization",
>         "name": "Finance",
>         "oid": 5,
>         "type": "department",
>         "effectivePeriod": {
>             "start": /Date(1259396001526)/,
>             "end": null
>         },
>         "children": {
>             "$ref": "http://localhost:8080/personnel/bureaucracy/object/5/children"
>         }
>     },
>     {
>         "class": "xs.personnel.Organization",
>         "name": "Logistics",
>         "oid": 14,
>         "type": "department",
>         "effectivePeriod": {
>             "start": /Date(1259396001526)/,
>             "end": null
>         },
>         "children": {
>             "$ref": "http://localhost:8080/personnel/bureaucracy/object/14/children"
>         }
>     },
>     {
>         "class": "xs.personnel.Position",
>         "name": "President",
>         "oid": 7,
>         "type": "President",
>         "effectivePeriod": {
>             "start": /Date(1259396001526)/,
>             "end": null
>         },
>         "children": {
>             "$ref": "http://localhost:8080/personnel/bureaucracy/object/7/children"
>         }
>     }
> ]
>
> However, these children are not rendered. Just a undefined node is shown
> under the root node. This seems the model (dijit.tree.ForestStoreModel) is
> not update after these children are fetched back.
>
> The following is the html markup for the tree.
>
>         <div dojoType="dijit.layout.ContentPane" region="leading"
> splitter="true" style="width:200px">
>             <div dojoType="dojox.data.JsonRestStore"
> jsId="bureaucracyStore" target="/personnel/bureaucracy/object"
> idAttribute:"oid">
>             </div>
>             <div dojoType="dijit.tree.ForestStoreModel"
> jsId="bureaucracyModel" store="bureaucracyStore"
>                 rootId="object" labelAttr="name" childrenAttrs="children">
>             </div>
>             <div dojoType="dijit.Tree" id="bureaucracy"
> model="bureaucracyModel" showRoot="false">
>             </div>
>         </div>
>
>
> Any clue?
>
> Regards,
> Rice
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.dojotoolkit.org/pipermail/dojo-interest/attachments/20091228/9629c4ef/attachment.htm 


More information about the Dojo-interest mailing list