3 Replies Latest reply on Aug 8, 2007 9:17 AM by ntsiii

    DataGrid Refresh

    SA_TPS
      Hey there. Sorry for the crosspost, I thought this would be a better place for this question.

      I'm trying to get a Datagrid to refresh itself after I call a function to change the data set I'm getting from a .ASP page doing SQL queries. The problem is, even though I'm recalling the <HTTPService> and getting new data, the Datagrid does not refresh to reflect the new data. Any ideas?

      Here's the code I've got for this component.

      quote:


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml" width="1030" height="874" creationComplete="userRequest.send()" borderStyle="none" cornerRadius="10">
      <mx:Script>
      <![CDATA[
      private function send_data():void
      {
      userRequest.send();
      }

      public var Airport:Boolean = false;
      public var Downtown:Boolean = false;
      public var Midtown:Boolean = false;
      public var Southwest:Boolean = false;
      public var West:Boolean = false;
      public var Toggle:String = "";

      private function Toggles(Toggle:String):void
      {
      if(Toggle == "Airport")
      {
      if (Airport == false)
      {
      Airport = true;
      Test.text = "true";
      }

      else
      {
      Airport = false;
      Test.text = "false";
      }
      }
      if(Toggle == "Downtown")
      {
      if (Downtown == false)
      {
      Downtown = true;
      Test.text = "true";
      }

      else
      {
      Downtown = false;
      Test.text = "false";
      }

      }



      //restDG.selectedIndex="0"
      }
      ]]>
      </mx:Script>


      <mx:HTTPService id="userRequest" url="DATAURL.ASP" useProxy="false" method="POST">
      <mx:request xmlns="">
      <airport>
      {Airport}
      </airport>
      <downtown>
      {Downtown}
      </downtown>
      </mx:request>

      </mx:HTTPService>
      <mx:VDividedBox x="10" y="10" height="100%" width="400">
      <mx:Panel width="100%" height="100%" layout="absolute">
      <mx:TabNavigator x="0" y="0" width="380" height="386">
      <mx:Canvas label="Location" width="369" height="357" borderStyle="solid">
      <mx:CheckBox x="10" y="10" label=" Airport" fontFamily="Verdana" fontWeight="bold" fontSize="20" change="{Toggles('Airport');send_data();}"/>
      <mx:CheckBox x="10" y="86" label=" Downtown" fontFamily="Verdana" fontWeight="bold" fontSize="20" change="{Toggles('Downtown');send_data();}"/>
      <mx:CheckBox x="10" y="154" label=" Midtown" fontFamily="Verdana" fontWeight="bold" fontSize="20"/>
      <mx:CheckBox x="10" y="226" label=" Southwest" fontFamily="Verdana" fontWeight="bold" fontSize="20"/>
      <mx:CheckBox x="10" y="294" label=" West" fontFamily="Verdana" fontWeight="bold" fontSize="20"/>
      <mx:Label x="218" y="124" id="Test"/>
      </mx:Canvas>
      <mx:Canvas label="Cuisine" width="370" height="100%">
      </mx:Canvas>
      <mx:Canvas label="Service &amp; Amenities" width="369" height="100%">
      </mx:Canvas>
      </mx:TabNavigator>
      </mx:Panel>

      <mx:DataGrid x="10" y="439" width="400" height="100%" dataProvider="{userRequest.lastResult.enter.reg}" fontSize="14" id="restDG" selectedIndex="0">
      <mx:columns>
      <mx:DataGridColumn headerText="Resturant Name" dataField="name" />
      </mx:columns>
      </mx:DataGrid>

      </mx:VDividedBox>
      <mx:Label x="522" y="6" text="{restDG.selectedItem.name}" fontSize="26" fontFamily="Verdana" color="#000000"/>
      <mx:Image x="418" y="10" source="{restDG.selectedItem.photo}"/>
      <mx:Label x="522" y="43" text="{restDG.selectedItem.address}" fontSize="15" fontFamily="Verdana" fontWeight="bold" color="#000000"/>
      <mx:Label x="522" y="66" text="{restDG.selectedItem.city},{restDG.selectedItem.state} {restDG.selectedItem.zip}" fontSize="15" fontFamily="Verdana" fontWeight="bold" color="#000000"/>
      <mx:Label x="522" y="89" text="{restDG.selectedItem.phonetxt}" fontWeight="bold" fontSize="15" fontFamily="Verdana" fontStyle="italic" color="#ff0000"/>
      <mx:Label x="591" y="89" text="{restDG.selectedItem.area_code}-{restDG.selectedItem.phone}" fontSize="15" fontFamily="Verdana" fontWeight="bold" color="#000000"/>
      <mx:Label x="522" y="112" text="{restDG.selectedItem.rangetxt}" fontFamily="Verdana" fontSize="15" fontWeight="bold" fontStyle="italic" color="#ff0000"/>
      <mx:Label x="638" y="112" text="{restDG.selectedItem.range}" fontFamily="Verdana" fontSize="15" fontWeight="bold" color="#000000"/>
      <mx:Label x="522" y="135" text="{restDG.selectedItem.avgtxt}" fontFamily="Verdana" fontSize="15" fontWeight="bold" color="#ff0000" fontStyle="italic"/>
      <mx:Label x="666" y="135" text="{restDG.selectedItem.avg_ticket}" fontSize="15" fontFamily="Verdana" fontWeight="bold"/>
      <mx:Label x="522" y="158" text="{restDG.selectedItem.seattxt}" fontFamily="Verdana" fontSize="15" color="#ff0000" fontWeight="bold" fontStyle="italic"/>
      <mx:Label x="679" y="158" text="{restDG.selectedItem.seating_capacity}" fontFamily="Verdana" fontSize="15" fontWeight="bold"/>

      </mx:Canvas>


        • 1. Re: DataGrid Refresh
          Level 1
          If you take the result from the httprequest and put it in an arraycollection object you can call refresh() on the arraycollection and It will refresh
          • 2. Re: DataGrid Refresh
            SA_TPS Level 1
            I think that might work, but now I'm getting an error trying to do the " public ar:DataService" I've got the mx.data.DataService; importing, but it's still giving me a "Type was not found or was not a compile-time constant: DataService" error.
            • 3. Re: DataGrid Refresh
              ntsiii Level 3
              Nothing in your post indicates you are using LCDS. What are you trying to do with "DataService"?

              Also, I advise against binding to lastResult because, as you are seeing, it is dificult to debug, and you have no idea where the failure is ocurring. Instead, use a result handler function.
              Tracy