4 Replies Latest reply on Mar 10, 2008 8:34 AM by MrSmeeth

    ItemRenderer and DataGrid Problem

    MrSmeeth
      Hi guys.

      I'm on creating a small app that simply pulls information from an XML file, displays it in a DataGrid then allows the user to filter and search it. First things first though; I'll explain what I have so far then detail my problem.

      I get the XML file via HTTPService then place the results in a Bindable ArrayCollection. When the Datagrid's source is set to that ArrayCollection it works fine. What I am initially trying to do is use an itemRenderer in one of the columns that displays lines of text depending on the values of the current row.

      For example, the structure of my XML file is (roughly):

      <content>
      <name>Name1</name>
      <description>Description Goes Here</description>
      <audience1>yes</audience1>
      <audience2>no</audience2>
      <audience3>yes</audience3>
      </content>

      So what I am trying to do is group the audiences that each piece of "content" has a yes value to. So under the "Audiences" column in the datagrid, the above content would say

      "Audience1
      Audience3"

      as it has a yes value in between audience 1 and 3. I've tried writing very basic code within the itemRenderer whereby I override the public function set data and do some checks there but it never seems to work right. I've tried using Arrays within that to store the current audiences but I clearly haven't got the right format for that.

      There must be a more efficient way of doing this. I'm fairly new to both Flex and AS3 (been using AS2 quite a while now) but I have a feeling there would be some way to store each row's audience list in an array/object/model so I can refer to it later (I'm intending to filter these results by audience type later so I think I will HAVE to do it this way eventually). I've read quite a few tutorials and guides but I honestly don't know where to look anymore, none of them seem to cover this specific problem.

      I hope this makes sense to you guys and any guidance you could give me would be greatly appreciated.

      Cheers