1 Reply Latest reply on Apr 26, 2007 1:20 AM by Rahul Mainkar

    controling a dataProvider result using a mx:HSlider...

    ljonny18 Level 1

      Hi I am a basic Flex 2 application showing the results and times for races and the individual runners in each race etc…. within my application I am using a remote object acting as my dataProvider communicating with ColdFusion and a CFC file containing different functions for the different races:

      <mx:RemoteObject id="RO_dataprovider" destination="ColdFusion" source="myCFC">
      <mx:method name="getDataStruct" result="handleResult_ getDataStruct (event)" fault="Alert.show(event.fault.message)"/>

      With the following actionScript:

      import mx.rpc.events.ResultEvent;

      public var structResult:Object;

      public function handleResult_ getDataStruct (event:ResultEvent):void {
      structResult=event.result as Object;

      I have various dataGrids and charts (lineCharts, barCharts, pieCharts etc) in the application – all using this same dataProvider:

      <mx:DataGrid id="cfcs_dg" width="100%" dataProvider="{structResult.RACE1}">
      <mx:DataGridColumn headerText="Competitor" dataField="comp"/>
      <mx:DataGridColumn headerText="Start Time" dataField="starttime"/>
      <mx:DataGridColumn headerText="End Time" dataField="endtime"/>
      <mx:DataGridColumn headerText="Total Time" dataField="totaltime"/>


      <mx:LineChart id="race1_lc" dataProvider="{structResult.RACE1}" width="100%">
      <mx:CategoryAxis dataProvider="{structResult.RACE1}" categoryField="totaltime"/> </mx:horizontalAxis>
      <mx:series> <mx:LineSeries yField="totaltime" displayName="Total Time Taken"/> </mx:series>
      <mx:Legend dataProvider="{race1_lc}"/>

      As you can imagine – if a race has lets say 400+ races in it (like a marathon for example) then a lot of data is going to be displayed within the charts (which is what I want) therefore making them complicated and in some cases complex and difficult to read / understand….

      However – I thought that I could include something to control (allow the user to control) the data and amount to view at one time that is coming from the dataProvider.
      In this case I want to control the total time “totaltime” entity so for example the user can choose to only show data for the racers that finished the race within 60 seconds – therefore not showing any of the slower times or data etc….

      I also thought a nice solution / possibility to this would be to somehow (and this is my problem) link my dataProvider to a slider or timeline: e.g. <mx:Hslider/> and control the “totaltime” displayed at any one time in the graphs / dataGrids using this slider.

      So my question is: is this actually possible to do, and if so could anyone give me some advice about how to go about doing it – or point me in the right direction???

      Much appreciated,

        • 1. Re: controling a dataProvider result using a mx:HSlider...
          Rahul Mainkar Level 1
          hi Jon,
          I faced the similar situation , only difference being, I was using webservice instead of Coldfusion as my dataprovider. This weservice was storing the data in XMl form. I had 2 options

          1. Use a filter function on the fetched XML
          2. use a querry in the webservice so that filtered data is collected.

          If your data is coming in XML format, then you can filter out required data using a function.

          I did something like this
          <mx:HSlider width="124" tickInterval="5" labels="[0,120]"
          id="totExp" values="0" maximum="120" snapInterval="5" showTrackHighlight="true"
          toolTip="Total Experience in months" />

          Here shoot is the function which has the code to filter data from the file.
          I hope this may give you a lil bit of direction.