2 Replies Latest reply on Aug 16, 2007 12:34 PM by j--d

    Filter Date Range

    j--d
      i am trying to Filter between Two Dates, looking for to get a date range. but as soon as i select the first date i get no data:

      Here is my code any help will be appreciate it

      Thank you
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      layout="vertical"
      creationComplete="initApp()">

      <mx:Script>
      <![CDATA[

      import mx.collections.ArrayCollection;
      import mx.rpc.events.ResultEvent;


      // On startup
      public function initApp():void
      {


      service.send();

      }


      // Filter function
      public function processFilter(item:Object):Boolean
      {
      var result:Boolean=false;

      if ((dateStart.selectedDate == null
      || dateStart.selectedDate <= siteDate)
      && (dateEnd.selectedDate == null
      || dateEnd.selectedDate >= item.siteDate))
      {
      result = true;
      }

      return result;
      }
      private function resultHandler(event:ResultEvent):void {
      myData = event.result as ArrayCollection;
      myData = event.result.root.data;
      myData.filterFunction=processFilter;

      }


      ]]>
      </mx:Script>

      <!-- Data (use ArrayCollection) -->

      <mx:HTTPService id="service" url="data/test.xml" result="resultHandler(event)" />

      <!-- UI -->
      <mx:ArrayCollection id="myData" />

      <mx:ApplicationControlBar width="100%">
      <mx:Label text="Show from"/>
      <mx:DateField id="dateStart" change="myData.refresh()" />
      <mx:Label text="to"/>
      <mx:DateField id="dateEnd" change="myData.refresh()" />
      </mx:ApplicationControlBar>

      <mx:DataGrid dataProvider="{myData}"
      width="100%" height="100%">


      </mx:DataGrid>


      </mx:Application>

      xml:


      Thank you for your reply here is my xml:

      Code:
      <root>
      - <data>
      <siteDate>2007/06/11</siteDate>
      <type>Agent</type>
      <count>2</count>
      </data>
      - <data>
      <siteDate>2007/06/11</siteDate>
      <type>Agent</type>
      <count>3</count>
      </data>
      - <data>
      <siteDate>2007/06/11</siteDate>
      <type>Agent</type>
      <count>T4</count>
      </data>
      <data>
      <siteDate>2007/07/11</siteDate>
      <type>Agent</type>
      <count>Monday</count>
      </data>
      - <data>
      <siteDate>2007/07/12</siteDate>
      <type>Most</type>
      <count>Tuesday</count>
      </data>
      - <data>
      <siteDate>2007/07/13</siteDate>
      <type>Choice</type>
      <count>Friday</count>
      </data>

      </root>