2 Replies Latest reply on Oct 26, 2009 9:53 AM by Shongrunden

    Using checkboxes to select items in a Spark DataGroup/List?

    Handycam Level 1

      I have a DataGroup from Catalyst, laid out like a tile list:

       

      Screen shot 2009-10-26 at 9.50.14 AM.png

       

      I'd like to do something a bit different, in that I'd like to allow people to multi-select items in the list using those checkboxes instead of the usual command/control-click.

       

      The checkbox, label and image are in the itemRenderer.  Is there an easy way that I can have that checkbox toggle the selected state of its list item?

        • 1. Re: Using checkboxes to select items in a Spark DataGroup/List?
          David_F57 Level 5

          Hi,

           

          Using the checkbox as a selection is easy enough as all you have to do is add a change event to the checkbox in the renderer and then in the event

           

          selected=mycheckbox.selected;

           

          The fun is how to handle the list click event from the checkbox you can stop propagation but if the item is clicked it will reset the selected indices.

           

          There is a few ways to handle this

           

          when processing the list don't use the selected indices just use the checkbox value to determine whats selected

          disable the listbox click event so items have to be selected with the checkbox

           

          or the most complex lots of overriding so that click acts like a ctrl/click and the checkbox/itemclick can toggle each other.

           

          David

          • 2. Re: Using checkboxes to select items in a Spark DataGroup/List?
            Shongrunden Adobe Employee

            I've actually been writing up a blog post on how to do something similar to this, but it isn't finished yet.  I'm hoping for a potential bug fix before I finish the post, but in the mean time you can see a sample of code you might find useful here:

             

            http://bugs.adobe.com/jira/browse/SDK-23778

             

            I extended List by creating a "CheckList" component that doesn't require holding down the Ctrl/Command key for multiple selection. (I removed Drag and drop support for simplicity).  Does this help at all?

             

            PS - Please vote on that bug if you believe that making that method protected would be useful to you.