6 Replies Latest reply on Feb 12, 2008 9:00 AM by jxmot

    need to create a "checkedlistbox"

    jxmot
      Hello,

      I need to create a custom component that has the following -

      - is a listbox that appears as a MS-VB checkedlistbox
      - ability to be loaded at runtime from a datasource (XML data file)

      I've searched forums and other websites looking for anything similar or any related information but haven't found anything.

      thanks in advance!
        • 1. Re: need to create a "checkedlistbox"
          Flex harUI Adobe Employee
          Try a List with itemRenderer="CheckBox"
          • 2. Re: need to create a "checkedlistbox"
            jxmot Level 1
            Thanks! That helped alot. I was able to get the checkboxes to show in the lists. But now I'm having a problem trying to determine how to make the checkboxes "dynamic" and read their labels from an XML file. I know I need a data source, I had that working for a grid.

            Here's an example of the data file I need to read into 4 lists -

            <?xml version="1.0" encoding="utf-8" ?>
            <DOCUMENT_ROOT>

            <list_1>list_1-item_1</list_1>
            <list_1>list_1-item_2</list_1>
            <list_1>list_1-item_3</list_1>
            <list_1>list_1-item_4</list_1>

            <list_2>list_2-item_1</list_2>
            <list_2>list_2-item_2</list_2>
            <list_2>list_2-item_3</list_2>
            <list_2>list_2-item_4</list_2>

            <list_3>list_3-item_1</list_3>
            <list_3>list_3-item_2</list_3>
            <list_3>list_3-item_3</list_3>
            <list_3>list_3-item_4</list_3>
            <list_3>list_3-item_5</list_3>
            <list_3>list_3-item_6</list_3>

            <list_4>list_4-item_1</list_4>
            <list_4>list_4-item_2</list_4>
            <list_4>list_4-item_3</list_4>

            </DOCUMENT_ROOT>
            • 3. Re: need to create a "checkedlistbox"
              ntsiii Level 3
              Alex, you know it is more complicated than that! (I am guessing at your identity, but confident)

              jxmot, there are several things that have to happen with an item renderer.
              1) They must be entirely data-driven(or static). That is, the checked state of the control must get its value from the list's dataProvider item, You can certainly get the label as well.
              2) If interactive (user can click), then that action must update the same dataProvider item property that was used to set the checked state.
              3) To access the checked states, you must loop over the dataProvider and examine that property. (there are other ways, like using a dictionary, but that is beyond the scope of this post)

              There are many ways to implement an item renderer.

              Google: Flex CheckBox itemRenderer

              You will find a wealth of examples.

              Tracy
              • 4. Re: need to create a "checkedlistbox"
                jxmot Level 1
                Tracy,

                Thanks for the help. But #2 and #1 have me a bit concerned that I may not be able to create what I need. I would like to create a checkbox list that obtains its labels from one source while being able to load and save the checked states to an XML file. Is that possible?

                Thanks!
                jim
                • 5. Re: need to create a "checkedlistbox"
                  ntsiii Level 3
                  No, that is ok. Tghe data-driven list is on thing, what you do with the updated data is someting else. The point is, you will need a collection that is the model for your list. The label, and the state of the checkbox must be in properties in each item in that list, and the dataProvider must update the "selected" property when a user clicks the checkbox.

                  Then, when you are ready, you can save that data however you want, either as it is, or preprocessing it as needed.

                  Tracy
                  • 6. Re: need to create a "checkedlistbox"
                    jxmot Level 1
                    This is starting to make more sense now... thanks! However I'm not sure yet how to read my XML data (see my 3rd post w/ the xml data in it) into an array or collection. That would take care of my checkbox labels.

                    Then after I've got the labels the data I want to read and use to check the boxes is -

                    <checkboxes>
                    <!-- Only one box to check -->
                    <list_1>list_1-item_3</list_1>
                    <!-- Multiple boxes to check, and -->
                    <!-- NOT contiguous -->
                    <list_2>list_2-item_1</list_2>
                    <list_2>list_2-item_3</list_2>
                    <list_2>list_2-item_4</list_2>
                    <!-- Same here -->
                    <list_3>list_3-item_1</list_3>
                    <list_3>list_3-item_2</list_3>
                    <list_3>list_3-item_5</list_3>
                    <list_3>list_3-item_7</list_3>
                    <!-- No checkboxes are to be clicked -->
                    <list_4></list_4>
                    </checkboxes>

                    Where "list_X-item_Y" is the label of a checkbox that was checked.