Changeset 13724

Show
Ignore:
Timestamp:
05/13/08 06:34:44 (2 months ago)
Author:
bill
Message:

Custom labels for Tree:

  • Add labelAttr parameter to store for simple way to override how label for each item is determined.
  • Add example file of different ways to override label for each item

Fixes #6065.
!strict

Location:
dijit/trunk
Files:
1 added
1 modified

Legend:

Unmodified
Added
Removed
  • dijit/trunk/Tree.js

    r13569 r13724  
    913913        null, 
    914914{ 
    915         // summary 
     915        // summary: 
    916916        //              Implements dijit.Tree.model connecting to a store with a single 
    917917        //              root item.  Any methods passed into the constructor will override 
     
    925925        //              one ore more attributes that holds children of a tree node 
    926926        childrenAttrs: ["children"], 
    927          
    928         // root: dojo.data.Item 
     927 
     928        // labelAttr: String 
     929        //              If specified, get label for tree node from this attribute, rather 
     930        //              than by calling store.getLabel() 
     931        labelAttr: "", 
     932  
     933        // root: dojo.data.Item 
    929934        //              Pointer to the root item (read only, not a parameter) 
    930935        root: null, 
     
    10481053        getLabel: function(/*dojo.data.Item*/ item){ 
    10491054                // summary: get the label for an item 
    1050                 return this.store.getLabel(item);       // String 
     1055                if(this.labelAttr){ 
     1056                        return this.store.getValue(item,this.labelAttr);        // String 
     1057                }else{ 
     1058                        return this.store.getLabel(item);       // String 
     1059                } 
    10511060        }, 
    10521061