0 Replies Latest reply on Oct 11, 2011 2:59 PM by apage3

    Add a for each script to loop through HTTPService?

    apage3

      I'm using Flash Builder 4 with the Flex 4.1 SDK.  I want to add a "for each" script to loop through my HTTPService XML file so only each nepName displays only once in my dropdown list.  In my XML file I have multiple records associated with nepName.  I would like ALL the records associated with each nepName to populate in my datagrid when it is selected from the dropdown.  Currently in my dropdown there is a nepName entry for each XML tag.  I hope I was able to explain that well enough. I'll try to put my code below so you can see everything I'm working with.

       

      MXML:

       

      <?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:esri="http://www.esri.com/2008/ags"
                     xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
                     creationComplete="nepInfo.send()">
          <s:layout>
              <s:VerticalLayout horizontalAlign="center" paddingTop="25"/>
          </s:layout>
          <fx:Declarations>
              <s:HTTPService id="nepInfo" url="http://www.epa.gov/owow/estuaries/nep_info.xml"/>
              <!--s:RadioButtonGroup id="optiongroup"/-->
          </fx:Declarations>
          
          <s:Panel title="NEP Project Information">
              <s:layout>
                  <s:VerticalLayout/>
              </s:layout>
              <s:HGroup verticalAlign="middle">
          <mx:Form x="188" y="34" width="338">
          <mx:FormItem label="Search for NEP Information:">
          <s:DropDownList enabled="true" id="dropDownList" prompt="Select NEP" dataProvider="{nepInfo.lastResult.records.record}" labelField="nepName">
          </s:DropDownList>
          </mx:FormItem>
          </mx:Form>        
              </s:HGroup>    
              <mx:DataGrid id="resultsGrid"
                           dataProvider="{dropDownList.selectedItem}"
                           visible="{dropDownList.selectedItem != null}" x="20" y="62" width="1166" height="620">
                  <mx:columns>
                      <mx:DataGridColumn dataField="projectName" headerText="Project Name" wordWrap="true"/>
                      <mx:DataGridColumn dataField="projectDescription" headerText="Project Description" wordWrap="true"/>
                      <mx:DataGridColumn dataField="acres" headerText="Acres" wordWrap="true"/>
                      <mx:DataGridColumn dataField="habitatDescription" headerText="Habitat Description" wordWrap="true"/>
                      <mx:DataGridColumn dataField="neportCategory" headerText="Habitat Category" wordWrap="true"/>
                      <mx:DataGridColumn dataField="restorationType" headerText="Restoration Type" wordWrap="true"/>
                      <mx:DataGridColumn dataField="leadPartner" headerText="Lead Partner" wordWrap="true"/>
                  </mx:columns>
              </mx:DataGrid>
          </s:Panel>
      </s:Application>
      

       

      XML: http://www.epa.gov/owow/estuaries/nep_info.xml

       

      Thank you in advance for your help!

      -Alison