Flex 3: should I provide prepared data to my component or make it to process data before display?

Posted by grapkulec on Stack Overflow See other posts from Stack Overflow or by grapkulec
Published on 2010-03-24T22:12:09Z Indexed on 2010/03/24 22:13 UTC
Read the original article Hit count: 368

Filed under:
|
|

I'm starting to learn a little Flex just for fun and maybe to prove that I still can learn something new :) I have some idea for a project and one of its parts is a tree component which could display data in different ways depending on configuration.

The idea

There is list of objects having properties like id, date, time, name, description. And sometimes list should be displayed like this:

  1. first level: date
  2. second level: time
  3. third level: name

and sometimes like this:

  1. first level: year
  2. second level: month
  3. third level: day
  4. fourth level: time and name

By level I mean level of nesting of course. So, we can have years, that have months, that have days, that have hours and so forth.

The problem

What could be the best way to do it? I mean, should I prepare data for different ways of nesting outside of component or even outside of flex? I can do it at web service level in C# where I plan to have database access layer and send to flex nice and ready to display XML or array of objects. But I wonder if that won't cause additional and maybe unneccessary network traffic.

I tried to hack some code in my component to convert my data objects into XML or ArrayCollection but I don't know enough of Flex and got stuck on elimination of duplicates or getting specific data by some key value. Usually to do such things I have STL with maps, sets and vectors and I find Flex arrays and even Dictionary a little bit confusing (I've read language reference and googled without any significant luck).

The question

So, to sum things up: should I give my tree component data prepared just for chosen type of display or should I try to do it internally inside component (or some helper class written in ActionScript)?

© Stack Overflow or respective owner

Related posts about flex3

Related posts about customcomponents