7 Replies Latest reply on Nov 11, 2010 2:49 PM by John Hall

    Spark list itemrenderer with checkboxes

    John Hall Level 4

      I have a calendar and as I create new items on the calendar, they are associated with certain types of calendar events. So if "Meeting" is checked, a particular color of item renderer on the calendar is created and that works fine.

       

      However, I'm trying to reverse the process so that when someone clicks on an item in the calendar, I dispatch a custom even that goes back to the list control with the various types of calendar events and tries to check solely the one/s associated with the calendar item.

       

      In the itemrenderer for the checkbox for the calendar event type, I receive the event fine, change the checkbox to selected and trace the checkbox.selected and it says it's checked.

       

      However, it's not really checked visually. I've tried invalidatingProperties ahead of time plus/or committing properties after setting the change, validating the display list, validating properties. You get the idea. Nothing I do seems to change the visual display of the checkbox despite tracing that the selection is true.

       

      Any suggestions.

       

      Thanks.

        • 1. Re: Spark list itemrenderer with checkboxes
          Matt Le Fevre Level 4

          what's your current code for it?

          • 2. Re: Spark list itemrenderer with checkboxes
            John Hall Level 4

            Hi Matt.

             

            The script inside the checkbox itemRenderer is:

             

            public function updateCheckbox(e:FormEvent):void {

                 var calendar:Calendar=e.calendar;

                 if (calendar.referenceGUID == timeslotPM.currentTimeslot.calendar.referenceGUID) {

                      checkBox.selected = true;

                 } else {

                      checkBox.selected = false;

                 }

                 Logger.info(this.name + ": " + this.checkBox.selected.toString());

            }

             

            and it traces

             

            renderers.Renderer_DivisionListCheckbox [81] :: CustomListItemRenderer: true

             

            but no visual updating of the checkBox.

            • 3. Re: Spark list itemrenderer with checkboxes
              Shongrunden Adobe Employee

              Just out of curiosity, if you set useVirtualLayout=false on the List does it work?

              • 4. Re: Spark list itemrenderer with checkboxes
                John Hall Level 4

                Worth a shot but no difference. Traces fine but no visual update.

                 

                I've also tried dispatching a dataChange event in the function (thinking there might be a scope problem) and setting a bindable checkBoxSelected variable to true or false and setting the checkbox to that, but that also didn't do anything (except trace very nicely as I would expect it to do).

                 

                I must be missing something simple. I've tried invalidateProperties, validateProperties, validateNow, invalidateDisplayList, validate .....

                 

                Yep, shotgun approach hasn't worked either.

                • 5. Re: Spark list itemrenderer with checkboxes
                  Matt Le Fevre Level 4

                  this sounds insanely familiar, i believe there was a similar issue  with an node's item renderer in a tree, which didn't update its icon when being opened.

                   

                   

                  if i remember correctly, i played around with the guys code and  actually introduced a new boolean variable on each object in the dataprovider, then altered that when needed. Then i bound  the object's variable to the displaycomponent in the renderer, and it worked.  I'd find it in my post history but it was a while back and i can only see the recent stuff. That might work, same principle with a checkbox.

                   

                   

                   

                  also have you also tried calling dataProviderName.refresh(); after?

                  • 6. Re: Spark list itemrenderer with checkboxes
                    John Hall Level 4

                    I did try refresh, but appreciate your thoughts. I've finally made some progress by greatly simplifying the whole affair. I honestly can't believe how difficult I make things sometimes. Instead of dispatching a custom event from another component and changing the data, I finally got a binding in the checkbox of itemRenderer itself that (so far) seems to work

                     

                    selected="{data.GUID == timeslotPM.currentTimeslot.calendar.referenceGUID}"/>

                     

                    I can't believe how many iterations of convoluted code I've been through to no avail and who knows in which scope things were acting. The only reason I'm a little cautious is that I don't yet have enough items to scroll off the screen to see if it virtualizes properly.

                     

                    However, I appreciate your help greatly. And that of Shongrunden who had a previous post suggesting creating a new classfactory for the itemrenderer on the fly. That didn't work but it ran me into a debug trace that made things dawn on me. Here's hoping I'm not back with a "I thought it worked, but.."

                     

                    Thanks again

                     

                    John

                    • 7. Re: Spark list itemrenderer with checkboxes
                      John Hall Level 4

                      Ah, I am back quickly to say that without his changing of the itemRenderer on the fly, it wouldn't work so the combo was the right binding within the itemRenderer and outside the component, managing the list's itemRenderer with

                       

                      divisionList.itemRenderer = null;

                      divisionList.selectedItems = timeslotPM.currentTimeslot.allowedDivisions;

                      divisionList.itemRenderer = new ClassFactory(renderers.Renderer_DivisionListCheckbox);