The Advanced Data Grid has the concept of Renderer Providers which is
pretty much what you are looking for, but the standard list control I
don't think can handle this gracefully.

So... a single column ADG? (Though I'd shoot one of our developers is
they suggested that ;) )

I'm not sure even suggesting overriding some of the more esoteric
functions in the List will help as the recycling is almost certain to
stuff you up!

 

So no, this can't be done simply in a List control.

 

Gk.

Gregor Kiddie
Senior Developer
INPS

Tel:       01382 564343

Registered address: The Bread Factory, 1a Broughton Street, London SW8
3QJ

Registered Number: 1788577

Registered in the UK

Visit our Internet Web site at www.inps.co.uk
<blocked::http://www.inps.co.uk/> 

The information in this internet email is confidential and is intended
solely for the addressee. Access, copying or re-use of information in it
by anyone else is not authorised. Any views or opinions presented are
solely those of the author and do not necessarily represent those of
INPS or any of its affiliates. If you are not the intended recipient
please contact [email protected]

________________________________

From: [email protected] [mailto:[email protected]] On
Behalf Of Thomas, Erik
Sent: 02 February 2009 21:06
To: [email protected]
Subject: [flexcoders] Need to render rows in a heterogeneous mx:List
differently based on each row's item data Type

 

Does anyone have a code sample of how I can supply a different
itemRenderer to a List based on the data Type of the item in any given
row?

 

I have a heterogeneous collection of Types in an ArrayCollection
(Property Sheet or User Preferences list) and want to render each row
differently based on the data Type of the row item.

 

For those of you familiar with MS WPF, it includes the notion of
something called a "DataTemplate" which is essentially an Item Renderer
that is used by the framework to render a particular data Type in a
heterogeneous collection or on a form. I'd like to do the same thing in
Flex within a List.

 

Is there such a notion in Flex? Can it be done simply?

 

I've tried implementing a Factory pattern where I supply a single
itemRenderer (VBox) class to the List component which is an ActionScript
class that simply overrides the "data" setter, and tests the Type of the
"data" property (the row item type) and if it's a certain Type it
instantiates or replaces a child container that properly renders the
data based on its Type. This is not a simple pattern to follow or
communicate. I'd like to find a simpler way.

 

I've also tried using a single renderer with multiple top level
components that use data binding to dynamically set "includeInLayout"
and "visible" so only one of the top level components will render. This
works, but the performance on a large list is abysmal in our ad hoc
tests. Simple renderers not using "includeInLayout" were much faster.

 

I've also tried using States to determine which part of the mxml to
render based on the Type, but the pattern is just too complicated and
too verbose.

 

I'm in search of the cleanest possible pattern to recreate what you get
out of the box with WPF, as I am sure someone at Adobe thought of this
(it's an amazingly common use case), but it's just a matter of my
learning how to do this.

 

Thanks for your suggestions!

 

Erik

 

Erik Thomas | Small Business Group, Intuit | Staff Engineer |
650-944-2602

 

 

Reply via email to