0 Replies Latest reply on Dec 14, 2009 10:17 PM by acoquinar

    Bug with advancedDataGrid !!!  ("groupIconFunction"  not working properly)

    acoquinar

      Suprisingly, the following code doesn't set an icon for the tree's second level of items.

       

      XML data is simplified here but it's only to make this simpler to read. (Just replace the path to your image file and run the thing. Have fun !)

       

      <?xml version="1.0"?>
      <!-- dpcontrols/adg/SimpleHierarchicalADGGroupIcon.mxml -->
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
      
        <mx:Script>
          <![CDATA[
                import mx.collections.ArrayCollection;
                          
              //  include "SimpleHierarchicalData.as";
      
               // Embed the icon for the groups.
                      [Bindable]
                      [Embed(source="assets/images/16/_hd.png")] 
                      public var hd:Class;
                      [Bindable]
                      [Embed(source="assets/images/16/_r.png")] 
                      public var r:Class;
              
               // Define the groupIconFunction callback function.
               public function myIconFunc(item:Object, depth:int):Class {
                   if(depth == 1)
                       // If this is the top-level of the tree, return the icon.
                       return hd;
                   if(depth == 2)
                       // If this is the top-level of the tree, return the icon.
                       return r;
                   else
                       // If this is any other level, return null.
                       return null;
               }
               
               
            ]]>
          </mx:Script>
       <mx:XMLList id="dpHierarchyXML" >
        <Region Region="Southwest">
         <Region Region="Arizona" Territory_Rep="Barbara Jennings" Actual="38865" Estimate="40000">
        
         </Region>
        </Region>
       </mx:XMLList>
          <mx:AdvancedDataGrid 
              width="100%" height="100%"
              groupIconFunction="myIconFunc"
               displayItemsExpanded="true" >
              <mx:dataProvider>
                  <mx:HierarchicalData source="{dpHierarchyXML}"/>
              </mx:dataProvider>
              <mx:columns>
                  <mx:AdvancedDataGridColumn dataField="@Region" itemRenderer="itemRender"/>
                  <mx:AdvancedDataGridColumn dataField="@Territory_Rep"
                      headerText="Territory Rep"/>
                  <mx:AdvancedDataGridColumn dataField="@Actual"/>
                  <mx:AdvancedDataGridColumn dataField="@Estimate"/>
              </mx:columns>
          </mx:AdvancedDataGrid>    
      </mx:Application>