Hi,
I’m using FlashBuilder 4 and trying to create a dropdownlist that populates a datagrid. The functionality is fine but my data is being chopped up too much. Currently every since “nepName” tag in my XML file is showing up in my dropdownlist (which makes for many duplicates of the same names) and only shows the data associated with that nepName tag. I want each nepName (by name ex. Barnegat Bay National Estuary Program) to display only once in my dropdownlist and populate my datadgrid with ALL the data in the XML file that is associated with that name. I’ve been looking for answers without success for a few weeks now and my deadlines are fast approaching. Please help! My code is below.
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:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import valueObjects.NEP;
[Bindable]
private var records:ArrayCollection;
protected function nepInfo_resultHandler(event:ResultEvent):void
{
records = event.result.records.record;
}
]]>
</fx:Script>
<fx:Declarations>
<s:HTTPService id="nepInfo" url="http://www.epa.gov/owow/estuaries/nep_info.xml"
result="nepInfo_resultHandler(event)"/>
<!--s:RadioButtonGroup id="optiongroup"/-->
</fx:Declarations>
<s:Panel title="NEP Project Information" width="1160">
<s:layout>
<s:VerticalLayout/>
</s:layout>
<s:HGroup verticalAlign="middle">
<mx:Form x="188" y="34">
<mx:FormItem label="Search for NEP Information:">
<s:DropDownList enabled="true" id="dropDownList" width="300" prompt="Select NEP" dataProvider="{records}" labelField="nepName">
</s:DropDownList>
</mx:FormItem>
</mx:Form>
</s:HGroup>
<s:Group id="projectData" width="1143" height="620">
<mx:DataGrid id="resultsGrid" width="1143"
dataProvider="{dropDownList.selectedItem}"
visible="{dropDownList.selectedItem != null}" x="0" y="0">
<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:Group>
<s:Scroller viewport="{projectData}"/>
</s:Panel>
</s:Application>
XML: http://www.epa.gov/owow/estuaries/nep_info.xml
ActionScript:
package valueObjects
{
public class NEP
{
public var nepName:String;
public var projectName:String;
public var projectDescription:String;
public var acres:String;
public var habitatDescription:String;
public var neportCategory:String;
public var restorationType:String;
public var leadPartner:String;
}
}
Thank you in advance,
Alison