Question

In my flex project I have a list with customized itemRenderer. I will provide data from a XML file. I want this itemRenderer

  1. Always contains only 6 items and not less and not more
  2. If the result of XML file contains less than 6 items (e.g 3 items), put the rest of items (remained 3 ones) a default item.

See screenshot:

Customized itemRenderer

Anybody has any suggestion?

Was it helpful?

Solution

I would create a data object class that contains a property to refer to an XML node. Then populate an ArrayCollection with new instances of that data object for each node you have in your XML data, with a max of 6. If you have less, keep adding data object instances, without adding an XML node reference (you won't have any to refer to).

Then in your itemrenderer, you can simply check if the data object contains an XML node or not. If it does, render its content, if not, render the default view.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top