2 Replies Latest reply on Aug 23, 2010 2:27 AM by jaya1685

    how to get data from a datagrid which is populate through XML

    jaya1685

      hi,

      I am generating a datagrid using a xml file,

      now i want to call another file by clicking on any of the item in the list,

      but the text value on which i am clicking should pass to the file.

      can anyone suggest how can i do this??below is the sample code i am using.

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                     xmlns:s="library://ns.adobe.com/flex/spark"
                      xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"  initialize="exp.send()">
         
          <fx:Declarations>
              
              <s:HTTPService id="exp" url="expLab1.xml" result="

      resultHandlerQuestionBar(event)"/>
             
          </fx:Declarations>
         
         
          <s:Panel x="74" y="218" width="485" height="333" title="Work On Configured Experiments" id="p1" fontSize="14" chromeColor="#9BFDAB" dropShadowVisible="false" contentBackgroundColor="#E4EEE6" contentBackgroundAlpha="1.0" backgroundColor="#67B6AC" textAlign="left">
               <mx:DataGrid  x="35" y="33" width="338" height="88" dataProvider="{experimentdetails}" chromeColor="#FCFCFC" contentBackgroundColor="#FFFFFF" selectionColor="#FAFBFD" rollOverColor="#FCFDFF" focusColor="#FCFDFD" itemClick="onItemClick( event );">
                   <mx:columns>
                      <mx:DataGridColumn id="j1" dataField="experimentName" headerText="" itemRenderer="jaya">
                      </mx:DataGridColumn>
                   </mx:columns>
              </mx:DataGrid>
          </s:Panel>
         
         
          <fx:Script>
              <![CDATA[
                  import mx.collections.ArrayCollection;
                  import mx.controls.Alert;
                   import mx.events.FlexEvent;
                  import mx.events.ListEvent;
                  import mx.rpc.events.ResultEvent;
                 
                 
                  [Bindable]
                  private var workbenchname:ArrayCollection;
                   //private var a:String;
                  private function resultHandlerQuestionBar(event:ResultEvent):void
                  {
                     experimentdetails=event.result.List.experimentList.experiment;  
                  }
                 
                 
                  [Bindable]
                  private var experimentdetails:ArrayCollection;
                   private var alert:Alert;
                  private function onItemClick( e:ListEvent ):void {
                     
                      alert=Alert.show("clicked "+j1.itemRenderer+" ok?" );
                     
                   }
              ]]>
          </fx:Script>
      </s:Application>

      and the xml file is:

      <?xml version="1.0" encoding="UTF-8"?>
      <List>
        <workbench>Basic Movement</workbench>
          <experimentList>
            <experiment>
              <experimentName>Distance with varying time</experimentName>
              <Rating>2</Rating>
              <expNO>1</expNO>
             
            </experiment>
            <experiment>
              <experimentName>Distance with Constant time</experimentName>
              <Rating>1</Rating>
              <expNO>2</expNO>
             
            </experiment>
            <experiment>
              <experimentName>Time taken while decelerating</experimentName>
              <Rating>3</Rating>
              <expNO>3</expNO>
             
            </experiment>
           </experimentList> 
          
      </List>