3 Replies Latest reply on May 31, 2009 3:46 AM by *Prashant Shelke*

    Getting info from advanceddatagrid. Please help me.

    scorptique Level 1

      I know http://forums.adobe.com/thread/131416 has the answer inside but i dont understand what it means (hierarchy and cursor thingies)  and how to use it. I only manage to understand until the getting selected index, and I got it. But I dont know how to use it to extract the data from that row and trace it out. please help me add on to my doubleClickHandler function. These are my codes.

       

      my xml file.

       

      <location locations="Singapore">

      <locations Region="north">
      <details l_id="7" l_title="Causeway Point" street="1 Woodlands Square, #01-39 Causeway Point"/>
      <details l_id="17" l_title="IMM Building" street="2 Jurong East Street 21, #01-51"/>
      </locations>

      <locations Region="west">
      <details l_id="4" l_title="Arena Country Club " street="511 Upper Jurong Road, #01-06"/>
      <details l_id="19" l_title="Jurong Point" street=" 63 Jurong West Central 3  #B1-54/55 Jurong Point"/>
      </locations>
      </location>

       

      ------------------------------------------------------------------------------------------ -------------

      my actionscript code in the main mxml file

       

      private function doubleClickHandler():void
                  {  
                      var item:Object = agd.selectedItem;
                      var index:int = agd.selectedIndex;
                     
                      if (!item || index == -1)
                      return ;
                      Alert.show("Double Clicked item index:" + index);            
                  }

       

      ------------------------------------------------------------------------------------------ ---------------

      <mx:AdvancedDataGrid id="agd"
      doubleClickEnabled="true" itemDoubleClick="doubleClickHandler()">
              <mx:columns>
                  <mx:AdvancedDataGridColumn dataField="@locations"
                      headerText="Location"/>
                  <mx:AdvancedDataGridColumn dataField="@l_title"
                      headerText="Title"/>
                  <mx:AdvancedDataGridColumn dataField="@l_street"
                      headerText="Street"/>
              </mx:columns>
          </mx:AdvancedDataGrid>

        • 1. Re: Getting info from advanceddatagrid. Please help me.
          _Natasha_ Level 4

          Hi,

          you've already extract data

          var item:Object = agd.selectedItem;

          it's item from dataProvider. You have XML dataProvider, so it's XML for this row.

          • 2. Re: Getting info from advanceddatagrid. Please help me.
            *Prashant Shelke* Level 4

            Hi,


            Please see following code,


                        private function doubleClickHandler(event:MouseEvent):void
                        {  
                            var item:Object = event.currentTarget.selectedItem;// if you know id for grid you can provide that also,
                            var index:int = event.currentTarget.selectedIndex;
                           

                            Alert.show("Double Clicked item index:" + index);// you have provided it after return so it wont come always!
                            if (item != null || index == -1)
                                  return ;

                            else

                                Alert.show("locations : " + item.@locations);

             

                        }


            Hope this will work for u.


            Thanks.

            • 3. Re: Getting info from advanceddatagrid. Please help me.
              *Prashant Shelke* Level 4

              Small correction in the code:


              private function doubleClickHandler(event:MouseEvent):void
                          {  
                              var item:Object = event.currentTarget.selectedItem;// if you know id for grid you can provide that also,
                              var index:int = event.currentTarget.selectedIndex;
                             

                             Alert.show("Double Clicked item index:" + index);// you have provided it after return so it wont come always!              

                                if (item != null && index > -1)

                                  Alert.show("locations : " + item.@locations);

               

                          }