0 Replies Latest reply on Mar 23, 2007 12:22 PM by ezschneids01

    Filtering XML File

    ezschneids01 Level 1
      Here is a synopsis of what I am attempting to accomplish (or what I think I should do, I could be wrong):

      I have my main MXML file with series of combobox menus, I then have a MXML component that I created that consists of a data grid and some graphs. In the component I have a HTTPService that calls on the XML file I then want to assign the data from the XML file to an ArrayCollection and filter the ArrayCollection based upon selections that I made in my combobox menus, I then use the Array Collection as the dataProvider for the charts and datagrids. I have included my code here in this post for reference, along with a sampling of what my XML file looks like. I have tried many things to no avail to get this to work.

      Note: I created the XML file from SQL Server

      If anyone has a solution to the problem I would be appreciative if you could share with me. Or if you have an idea of a better process that would be good as well. Thank you all in advance for your help.

      Snippet From XML File (for security reasons I have changed some of the data but the format is the same):

      <?xml version="1.0"?>
      <ROOT>
      <reference_ClicksCreativeYTD FUNDING_SOURCE="Funding Source" DIVISION="Division" DMA="DMA" BUY_TYPE="Buy Type" CREATIVE_GROUP_1="CG1" DEL_IMPS="####" DEL_CLICKS="####" CTR="####"/>
      ... (File continues on about 250 items)
      </ROOT>

      MXML Code:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Panel xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="onCreationComplete()" xmlns="*" layout="absolute" width="490" height="364" backgroundColor="#ffffff" borderColor="#b4b4b4" title="Creative Strategy Vs. Message - &lt;Dynamic Label&gt;" fontWeight="bold" fontSize="12" fontFamily="Arial">
      <mx:Script>
      <![CDATA[

      import mx.managers.PopUpManager;
      import mx.core.IFlexDisplayObject;
      import mx.rpc.events.ResultEvent;
      import mx.rpc.events.FaultEvent;
      import mx.rpc.events.InvokeEvent;
      import mx.controls.Alert;
      import mx.managers.CursorManager;
      import mx.collections.ArrayCollection;

      public var caller:DashLMGRevised;

      [Bindable]
      private var acCreative:ArrayCollection;

      private function onCreationComplete():void
      {
      ClicksCreativeYTDXML.send();
      }

      private function onInvoke(event:InvokeEvent):void
      {
      CursorManager.setBusyCursor();
      }

      private function onResult(event:ResultEvent):void
      {
      acCreative = event.result.ROOT.reference_ClicksCreativeYTD;
      acCreative.refresh();
      acCreative.filterFunction = AryFilter;
      colx.dataProvider = acCreative;
      cols.dataProvider = acCreative;
      line.dataProvider = acCreative;
      dgCreateCompare.dataProvider = acCreative;
      CursorManager.removeBusyCursor();
      }

      private function onFault(event:FaultEvent):void
      {
      Alert.show(event.fault.message);
      CursorManager.removeBusyCursor();
      }

      public function AryFilter(item:Object):Boolean
      {
      var result:Boolean=false;

      if ((item.DIVISION == caller.cbDivision.value) && (item.DMA == caller.cbDMA.value) && (item.FUNDING_SOURCE == caller.Funding.value) && (item.BUY_TYPE == caller.Strategy.value)) {
      result=true;
      }
      return result;
      }

      private function showCreativeCompare():void
      {
      var helpwindow:IFlexDisplayObject=PopUpManager.createPopUp(this,enlargeCreativeCompare,false) ;
      }

      private function updateCreateCompare():void
      {
      var helpwindow:IFlexDisplayObject=PopUpManager.createPopUp(this,updateCreativeCompare,false);
      }
      ]]>
      </mx:Script>

      <mx:HTTPService id="ClicksCreativeYTDXML" url="ClicksCreativeYTD.xml" invoke="onInvoke(event)" result="onResult(event)" fault="onFault(event)" resultFormat="e4x"/>

      <mx:Style source="/Styles/JoshuaCSS.css" />
      <mx:ViewStack x="0" y="0" id="vsCreateCompare" width="100%" height="100%">
      <mx:VBox x="0" y="0" height="100%" id="vbCreateCompareChart" icon="@Embed('icon_chart.png')" width="100%">
      <mx:ColumnChart id="colClicksCreateYTD" width="100%" height="100%">
      <mx:horizontalAxis>
      <mx:CategoryAxis id="colx" categoryField="CREATIVE_GROUP_1"/>
      </mx:horizontalAxis>

      <mx:verticalAxis>
      <mx:LinearAxis minimum="0" maximum="200000"/>
      </mx:verticalAxis>

      <mx:series>
      <mx:ColumnSeries id="cols" displayName="Series 1" yField="DEL_IMPS" xField="CREATIVE_GROUP_1"/>
      </mx:series>

      <mx:secondVerticalAxis>
      <mx:LinearAxis minimum="0" maximum="1"/>
      </mx:secondVerticalAxis>

      <mx:secondVerticalAxisRenderer>
      <mx:AxisRenderer placement="left" tickPlacement="inside"/>
      </mx:secondVerticalAxisRenderer>

      <mx:secondSeries>
      <mx:ColumnSeries id="line" displayName="Series 2" yField="CTR" xField="CREATIVE_GROUP_1"/>
      </mx:secondSeries>
      </mx:ColumnChart>
      </mx:VBox>
      <mx:VBox x="0" y="0" height="100%" width="100%" id="vbCreateCompare" icon="@Embed('icon_grid.png')">
      <mx:DataGrid width="100%" height="100%" id="dgCreateCompare">
      <mx:columns>
      <mx:DataGridColumn headerText="Creative Group" dataField="CREATIVE_GROUP_1"/>
      <mx:DataGridColumn headerText="Delivered Clicks" dataField="DEL_CLICKS"/>
      <mx:DataGridColumn headerText="Delivered Impressions" dataField="DEL_IMPS"/>
      <mx:DataGridColumn headerText="Click Through Rate (CTR)" dataField="CTR"/>
      </mx:columns>
      </mx:DataGrid>
      </mx:VBox>
      </mx:ViewStack>
      <mx:ControlBar y="271" id="conbarCreateCompare" verticalAlign="middle" width="92" height="28" horizontalAlign="center">
      <mx:ToggleButtonBar dataProvider="{vsCreateCompare}" id="toggleClicksCreateCompare" width="60" height="20" fontSize="10" fontWeight="bold"/>
      <mx:Button label="Enlarge" width="60" id="btnEnlargeInsights" click="showCreativeCompare();" height="20" fontSize="10" fontWeight="bold"/>
      <mx:Button label="Update" id="btnUpdateInsights" width="60" click="updateCreateCompare();" height="20" fontSize="10" fontWeight="bold"/>
      </mx:ControlBar>

      </mx:Panel>

      Again thank you all for your help.