0 Replies Latest reply on Nov 14, 2006 11:24 AM by JackBah

    Refresh Component After sorting dataprovider

    JackBah
      Hi,
      I'm trying to refresh a custom component that displays a dataprovider which I sort. Below is my code. Thanks in advance.

      ... // one of the sorting functions
      private function sortOnDate():void
      {
      var sortDate:Sort = new Sort();
      sortDate.fields = [new SortField("date", true, true), new SortField("reviewer")];
      reviewsCollection.sort = sortDate;
      reviewsCollection.refresh();
      //reviews = reviews.sortOn("date");

      }
      ...


      <mx:DateFormatter id="df" formatString="MMMM DD, YYYY"/>

      <mx:HBox horizontalGap="4" width="100%" horizontalAlign="left">
      <mx:Label text="Reviews" fontSize="12" fontWeight="bold"/>
      </mx:HBox>

      <mx:VBox id="reviewsBox" width="100%" height="100%" minHeight="0" borderStyle="outset" verticalGap="0" horizontalScrollPolicy="off">

      <mx:HBox id="header" paddingLeft="4" width="100%" backgroundColor="#CCCCCC">
      <mx:Label text="Rating" width="100" click="sortOnRating();"/>
      <mx:VRule height="18"/>
      <mx:Label text="Reviewer" width="120" click="sortOnReviewer();"/>
      <mx:VRule height="18"/>
      <mx:Label text="Date" width="120" click="sortOnDate();"/>
      </mx:HBox>

      <mx:DataGrid id="dg" dataProvider="{reviewsCollection}" width="100%" height="50%">

      <mx:columns>
      <mx:Array>
      <!-- Something that shows that the data provider gets sorted based on the reviewer -->
      <mx:DataGridColumn dataField="reviewer" headerText="Reviewer"/>

      </mx:Array>
      </mx:columns>
      </mx:DataGrid>

      <!-- Custom Repeater Component that takes reviewsCollection as the dataProvider -->
      <ReviewThumbnailRepeater id="rtr" dataProvider="{reviewsCollection}" project="{project}" width="100%"/>

      </mx:VBox>
      </mx:VBox>


      Here's the question. How can I make the custom component redraw after the data provider is sorted?