Show
Ignore:
Timestamp:
09/20/07 22:56:56 (16 months ago)
Author:
bill
Message:

Refactor tree to have a special node (without a corresponding item) at the top of
the tree, so that (for example) the continents/countries tree in test_Tree.html can
have a top node marked "Continents" even though there is no such item in the
data store.

This change requires handlers like onClick() to not fail when item==null, but
rather to assume that's the root node.

Fixes #4527, #4419, #4457.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • dijit/trunk/tests/tree/test_Tree_DnD.html

    r10488 r10580  
    1111                @import "../css/dijitTests.css"; 
    1212                @import "../dndDefault.css";  
    13  
    14                 @import "../../../dojo/resources/dojo.css"; 
    15                 @import "../../../dojo/resources/dnd.css"; 
    16                 @import "../../../dojo/tests/dnd/dndDefault.css"; 
    17  
    18  
    19  
    20  
     13                @import "../../../dojo/resources/dojo.css"; 
     14                @import "../../../dojo/resources/dnd.css"; 
     15                @import "../../../dojo/tests/dnd/dndDefault.css"; 
    2116        </style> 
    2217 
     
    4035 
    4136                globalId=1000; 
     37                lastSelected=null; 
    4238 
    4339                dojo.addOnLoad(function(){ 
     
    6460                                        parent: lastSelected,            
    6561                                        attribute: "children"    
    66                                 } 
     62                                }; 
    6763 
    6864                                //store.newItem({name: dojo.byId('newCat').value, id:globalId++, numberOfItems:dojo.byId('numItems').value}, pInfo); 
     
    118114                function tree2CheckItemAcceptance(node,source) { 
    119115                        var item = this.tree._domElement2TreeNode(node).item; 
    120                         if (this.tree.store.hasAttribute(item,"numberOfItems")){ 
     116                        if (item && this.tree.store.hasAttribute(item,"numberOfItems")){ 
    121117                                var numItems=this.tree.store.getValues(item, "numberOfItems"); 
    122118                                return true; 
     
    145141 
    146142                function getIcon(item) { 
    147                         if (catStore.hasAttribute(item, "numberOfItems")) { 
     143                        if (!item || catStore.hasAttribute(item, "numberOfItems")) { 
    148144                                console.log("returning folder class"); 
    149145                                return "myFolder"; 
     
    152148                        return "myItem" 
    153149                } 
    154  
    155150        </script> 
    156151 
     
    178173        <div dojoType="dojo.data.ItemFileWriteStore" jsId="catStore" 
    179174                url="categories.json"></div> 
    180  
    181  
    182  
    183175 
    184176        <table width="100%" style="margin:5px solid gray" > 
     
    218210                        <h2>Collection Count Summary</h2> 
    219211                        <p>You can't drop items onto this tree.</p> 
    220                         <div class="container" dojoType="dijit.Tree" id="myTree" store="catStore" labelAttr="name" getLabel="tree1CustomLabel"  childrenAttr="children" dndController="dijit._tree.dndSource" checkAcceptance="dndAccept" getIconClass="getIcon"></div> 
     212                        <div class="container" dojoType="dijit.Tree" id="myTree" store="catStore" label="Collections" 
     213                                labelAttr="name" getLabel="tree1CustomLabel"  childrenAttr="children" dndController="dijit._tree.dndSource" 
     214                                checkAcceptance="dndAccept" getIconClass="getIcon"></div> 
    221215                </td> 
    222216                <td> 
    223217                        <h2>Collection</h2> 
    224218                        <p>Drop items onto this tree, but only on categories, should fail to let you drop on other items.</p> 
    225                         <div class="container" dojoType="dijit.Tree" id="myTree2" store="catStore"  labelAttr="name"  childrenAttr="children, items" dndController="dijit._tree.dndSource" onDndDrop="tree2CustomDrop" checkAcceptance="dndAccept" checkItemAcceptance="tree2CheckItemAcceptance" getIconClass="getIcon"></div>  
     219                        <div class="container" dojoType="dijit.Tree" id="myTree2" label="Collections" store="catStore"  labelAttr="name"  childrenAttr="children, items" dndController="dijit._tree.dndSource" onDndDrop="tree2CustomDrop" checkAcceptance="dndAccept" checkItemAcceptance="tree2CheckItemAcceptance" getIconClass="getIcon"></div>  
    226220                </td> 
    227221        </tr> 
    228222        </table> 
    229223 
    230  
    231224        </body> 
    232225</html>