Posted a response to another responder in the thread...

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], "Alex Harui" <[EMAIL PROTECTED]> 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:[EMAIL PROTECTED] On
> Behalf Of Alex
> Sent: Friday, December 21, 2007 2:11 PM
> To: [email protected]
> 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