1 Reply Latest reply on Jul 18, 2012 8:47 AM by roydene

    Advanced Data Grid - Parent Level

    roydene Level 1

      Hi there,

       

      I am trying to get the parent level of an advanced data grid and enable a delete button when it is selected.

       

       

         [Bindable]

         private var dpHierarchy:ArrayCollection = new ArrayCollection([

           {Form:"SR1", Level:"root", children: [

            {Form:"SR1.swf"},

            {Form:"SR1Module.swf"},

            {Form:"Test Data", children: [

             {Form:"SR2"},

             {Form:"SR2"}

            ]

           }]},

           {Form:"MBR2", Level:"root", children: [

            {Form:"MBR2.swf"},

            {Form:"MBR2Module.swf"},

            {Form:"Test Data", children: [

             {Form:"SR2"},

             {Form:"SR2"}

            ]

           }]}    

         ]);

       

       

        <mx:AdvancedDataGrid id="adg" left="10" right="10" top="10" width="100%" height="250" itemClick="adg_itemClickHandler(event)">

         <mx:dataProvider>

          <mx:HierarchicalData source="{dpHierarchy}"/>

         </mx:dataProvider>

         <mx:columns>

          <mx:AdvancedDataGridColumn dataField="Form" headerText="Flex Forms"/>   

         </mx:columns>

        </mx:AdvancedDataGrid>

       

        <s:Button label="Delete" enabled="false" icon="@Embed('assets/delete.png')"/>

       

      Is there a way that I can check for this?  I even considered looking for the "Level: root" element but can't seem to get it.  Is there a way to do this?

       

      Thanks,

       

      Roy

        • 1. Re: Advanced Data Grid - Parent Level
          roydene Level 1

          Okey dokey - seems like I found a way around this

           

             protected function adg_itemClickHandler(event:ListEvent):void

             {

              if (event.itemRenderer.data.Level == "root"){

               btnDeleteForm.enabled = true;

              }

              else{

               btnDeleteForm.enabled = false;

              }

             }

           

          Seems to work 100%