Thanks for the clarification on recycle. 

In my case the dataset is changed when it is sorted in dataGrid view
by clicking on the column header (the data is otherwise static and no
scrolling is involved as I only have 3 data items). 

As the 2 views (dataGrid and tileList) share a common dataProvider my
expectation is that the sort in one view will be visually represented
in another.

I have vastly simplified the application source to focus on the
problem and what I find is that my itemRenderer for the tileList view
if coded as follows works showing the expected sort in both views:

    <mx:Label text="{data.name}"/>

If coded as follows (as I want, so that I can override the renderer
and provide a different attribute other than 'name' for a label) the
issue with incorrect sorting in tileList view arises:

   <mx:Label text="{thumbLabel}"/>

where the following is also defined
 
   /**
   * Retrieve the label to be used for the thumbnail 
   * associated with each data item. This method may 
   * be overridden in a derived class to customize 
   * the icon label associated with the thumbnail 
   * for each data item.
   */
   public function get thumbLabel(): String {
       return data.name;
   }

Is there a solution which will allow me to provide the string to be
displayed via a function? The intent is to be able to override the
thumbLabel function in an itemRenderer derived from this 'base'
itemRenderer class for cases where the dataset displayed uses an
attribute named other than 'name', for example an override might
simply return data.title or even conditionalize the string returned
based on other data attributes.

As I suggested the source for this entire simplified application is
now something that I could provide as I've boiled it down
substantially. The above issue is however the crux of the problem in
both the simplified sample and the original application.

Thanks for your continued assistance.
Alex M

PS: The tileList is defined as follows 

<mx:TileList id="grid" 
  itemRenderer="components.CEMDataviewThumbGeneratorIcon" 
  left="0" right="0" top="0" bottom="0" />

The CEMDataviewThumbGeneratorIcon as follows

<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml";>
 
   <mx:Script>
        <![CDATA[

            public function get thumbLabel(): String {
                return data.name;
            }
        ]]>
    </mx:Script>

        <mx:Label text="{thumbLabel}"/>
</mx:VBox>



 --- In [email protected], "Tracy Spratt" <[EMAIL PROTECTED]> wrote:
>
> Alex, "recycle" means that in a list based component, item renderer
> instances are only created for the visible rows, plus a few more for
> buffering.  When the underlying dataProvider of the list is changed, or
> sorted, or really touched in any most any way, or when the list is
> scrolled,  the framework re-sets the "data" property of each renderer,
> passing in the dataProvider item. (and calls invalidateProperties())
> 
>  
> 
> So any visual aspect of the renderer that depends on the underlying data
> item must be re-calculated and re-displayed whenever that 'data"
> property changes. (really a bit later, see Alex H's blog )
> 
>  
> 
> You can not do it in the initialize, or creationComplete events, because
> those get called once, when the component first instantiates.
> 
>  
> 
> I can't tell from your posting how you are handling this.
> 
>  
> 
> Tracy
> 
>  
> 
> ________________________________
> 
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of Alex
> Sent: Thursday, December 27, 2007 2:45 PM
> To: [email protected]
> Subject: [flexcoders] Re: tileList displaying items order other than
> that represented by dataProvider
> 
>  
> 
> interestingly I find that any if the itemRenderer's methods to
> retreive data as part of drawing the items is only called the 1st time
> the item is rendered. Switching views, even resorting in grid view and
> re-displaying the view stacks' tile view (where the renderer is
> drawing the icon representation of the tiled items) does NOT result in
> the item renderer being called on any of the subsequent displays of
> the tile/icon view. 
> 
> In a reply to the other response to my initial posting I suggested
> that I had 2 instances of this viewstack in my application, an 'old'
> one and a new one in which I'm attempting to component-ize the
> viewstack with 'N' views of the same dataset. The old implementation
> works, the new doesn't. In both implementations the above behavior of
> only calling the itemRenderer the 1st time each tile is rendered is
> observed so that in and of itself is not an issue apparently.
> 
> --- In [email protected] <mailto:flexcoders%40yahoogroups.com>
> , "Alex" <mcleod_alex@> wrote:
> >
> > Thanks for the tip
> > 
> > From your blog entry I read "Recycle" to mean that I need an else
> clause wherever I have 
> > an if to ensure that the 'unhandled' condition is handled and some
> value for an attribute is 
> > always set.
> > 
> > The renderer I have coded either always returns a value from its
> methods (i.e., no 
> > conditional statements) or where there IS an if clause there also
> needs to be an else to 
> > ensure that a value for the desired attribute is always provided.
> > 
> > If my interpretation of 'recycle' is not correct please let me know.
> > 
> > Thanks!
> > Alex
> > 
> > --- In [email protected]
> <mailto:flexcoders%40yahoogroups.com> , "Alex Harui" <aharui@> wrote:
> > >
> > > Are you using a custom renderer? Sounds like it doesn't know how
> to be
> > > recycled. More about renderer recycling on my blog
> > > (blogs.adobe.com/aharui)
> > > 
> > > ________________________________
> > > 
> > > From: [email protected]
> <mailto:flexcoders%40yahoogroups.com> 
> [mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
> ] On
> > > Behalf Of Alex
> > > Sent: Friday, December 21, 2007 2:11 PM
> > > To: [email protected] <mailto:flexcoders%40yahoogroups.com>
> 
> > > Subject: [flexcoders] tileList displaying items order other than
> that
> > > represented by dataProvider
> > > 
> > > 
> > > 
> > > I have a problem with a viewStack that has 2 views, a dataGrid and a
> > > tileList view both of which which share a common dataProvider.
> > > 
> > > - The tileList uses an itemRenderer to draw an icon/name for each
> item.
> > > - The datagrid affords the ability to sort the displayed items by
> > > clicking on the column headers.
> > > 
> > > The initial display of both views is as expected, the sort order in
> > > the tileList view matches that of the items in the dataGrid view.
> > > 
> > > A "trace" of the data items in the dataProvider invoked whenever I
> > > switch between views [via trace(datagrid.dataProvider) and
> > > trace(tilelist.dataProvider)] both show the items in the list in the
> > > order expected regardless of how many times I switch views back and
> > > forth.
> > > 
> > > The items (a ListCollectionView of items of type "Foo") listed by
> the
> > > trace as expected reflect the format of the "toString" function in
> the
> > > Foo class.
> > > 
> > > Now the problem...
> > > 
> > > 1) When I click a header in the dataGrid view to re-sort the data
> > > subsequent trace output of the dataProvider's list of objects
> changes
> > > to another format:
> > > 
> > > (Array)#0
> > > [0] (com.emc.sspg.cem.data::Foo)#1
> > > attribute1_name = value1
> > > attribute2_name = value2
> > > [1] (com.emc.sspg.cem.data::Foo)#1
> > > 
> > > etc.
> > > 
> > > I'm not sure why this happens..
> > > 
> > > 2) The array elements in the trace output are reordered to reflect
> the
> > > expected sort order as displayed in the dataGrid view AND the
> tileList
> > > view BUT the order of the actual icons drawn in the tileList view
> does
> > > not match the order of the items traced. (In fact I've yet to be
> able
> > > to discern what order they are now drawn in, its not the original
> > > "pre-sorted" order either.)
> > > 
> > > ---------
> > > 
> > > Another subtlety my trace statements have pointed out is that only
> the
> > > 1st time the icon view is drawn do the item renderers get called to
> > > actually get the icon and name to display.
> > > 
> > > Solution-wise, while not a great solution I've tried to insert
> various
> > > functions to invalidate the drawing such that subsequent views of
> the
> > > icon view would re-call the renderers to prove to me that they are
> > > being drawn in the order that I'm seeing them left-to-right,
> > > top-to-bottom in the tileList but none of the following cause that
> to
> > > occur.
> > > 
> > > tilelist.invalidateDisplayList();
> > > tilelist.invalidateList();
> > > tilelist.invalidateProperties();
> > > tilelist.dataProvider.refresh();
> > > 
> > > Any thoughts regarding this would be appreciated.
> > > 
> > > Thanks
> > >
> >
>


Reply via email to