4 Replies Latest reply on May 23, 2008 1:41 PM by ntsiii

    Dynamic checkboxes

      Hi, I'm trying to create a bunch of checkboxes based on a xml file, The idea would be something like a tree, but with checkboxes instead of the elements inside a branch of a tree, you know, like:
      class 1:
      [] topic 1
      [] topic 2
      [] topic 3
      class 2:
      [] media 1
      [] media 2
      [] media 3

      The problem is that I haven't seen anything like it and I would not like to harcode it inside the flex program, I was thinking about using a repeater but I don't know how to approach this problem so it fits inside the form I have, it's 500px wide, 600px high and the checkboxes would be a lot, the form is already inside an accordion.

      I don't know what other information would be necessary, I appreciate any light anyone can shed over this, thanks.
        • 1. Re: Dynamic checkboxes
          EvolvedDSM Level 2
          Well as far as a repeater goes, you could try something like the code I've got below. You will need to establish a dataprovider to give your repeater something to repeat!

          This example assumes your table has a column named 'title' (text type) and a column named 'isChecked' (boolean type). The title column is the title or description of your table records and the isChecked column signifies the true/false or yes/no property of your record.

          <mx:Repeater dataProvider="{your_dataprovider}" id="repeatid">
          <mx:Label text="{repeatid.currentItem.title}"/>
          <mx:CheckBox selected="{repeatid.currentItem.isChecked}"/>

          • 2. Re: Dynamic checkboxes
            ntsiii Level 3
            Also, I advise putting your repeated controls into a custom component and repeat that. Pass in a reference to the entire currentItem, and expose the item in a public property. This will simplify click handling immensely. I'll post some example code later.

            • 3. Re: Dynamic checkboxes
              Xyrer Level 1
              Actually, now that evolvedDSM shows it that way, I would think that advanced data grid is a better choice, that way I can use a tree, and the checkboxes on another column, and the space is no problem here.
              Am I right? I'm gonna test it and post.
              • 4. Re: Dynamic checkboxes
                ntsiii Level 3
                Sure, DataGrid is better if you have a lot of items.

                Item Renderers, are a bit tricky. Do not start from scratch, but find an example an modify it. I have a checkbox example on www.cflex.net.