Not at all.  Overriding the set data function is commonly used.  
What feels dirty and hackish to me, is getting the data inside of 
the itemRenderer instead of passing it in from the parent.  .02 :)

-TH

--- In flexcoders@yahoogroups.com, "ben.clinkinbeard" 
<[EMAIL PROTECTED]> wrote:
>
> OK, putting a small flag into the function that checks to see if 
the
> data is actually new seems to be a decent way around the firing 
when
> scrolling, but it feels kinda dirty and hackish.
> 
> private var str_label:String;
>                       
>                       override public function set data
(value:Object):void
>                       {
>                               use namespace 
DOCUMENT_METADATA_NAMESPACE;
>                               var q:QName = new QName
(DOCUMENT_METADATA_NAMESPACE, "PlanNumber");
>                               
>                               super.data = value;
>                               
>                               if(data[q] != str_label)
>                               {
>                                       cb_planNumber.label = 
str_label = data[q];
>                                       cb_planNumber.selected = 
false;
>                               }
>                       }
> 
> Can someone, ideally from Adobe, confirm or deny my thought that 
the
> event being dispatched on scroll is a bug?
> 
> Thanks,
> Ben
> 
> 
> --- In flexcoders@yahoogroups.com, "Tim Hoff" <TimHoff@> wrote:
> >
> > Hi Ben,
> > 
> > As Stacey suggests, put this function in your itemRenderer:
> > 
> > override public function set data(value:Object):void {
> >      super.data = value;
> >      cb_planNumber.selected = false;
> > }
> > 
> > Everytime the data changes in the itemRenderer, the function 
will 
> > execute.
> > 
> > -TH
> > 
> > --- In flexcoders@yahoogroups.com, "ben.clinkinbeard" 
> > <ben.clinkinbeard@> wrote:
> > >
> > > I'm sorry Stacey, I don't follow. Can you please explain 
further?
> > > 
> > > Thanks,
> > > Ben
> > > 
> > > --- In flexcoders@yahoogroups.com, "Stacey Mulcahy" <stacey@> 
> > wrote:
> > > >
> > > > Can you not overwrite the data property it sets using the 
> > override and
> > > > setting the data of the super to the value and doing what 
you 
> > want?
> > > > 
> > > >  
> > > > 
> > > > Override public function set data (value:object):void{ 
> > super.data=value;
> > > > cb_planNumber.selected=value.someBoolean// do stuff }
> > > > 
> > > >   _____  
> > > > 
> > > > From: flexcoders@yahoogroups.com 
> > [mailto:[EMAIL PROTECTED] On
> > > > Behalf Of ben.clinkinbeard
> > > > Sent: Tuesday, July 18, 2006 1:01 PM
> > > > To: flexcoders@yahoogroups.com
> > > > Subject: [flexcoders] Re: How do I reset itemRenderer inside
> > > DataGrid when
> > > > dataProvider is updated?
> > > > 
> > > >  
> > > > 
> > > > Thanks for the reply, Tim. Unfortunately, the selected state 
is 
> > not
> > > > held in the data. The checkboxes should always begin 
unchecked, 
> > but
> > > > the user can (obviously) check them. The checkboxes 
apparently 
> > get
> > > > reused though, not all created every time, because
> > > > cb_planNumber.selected = false; does not work either.
> > > > 
> > > > Thanks,
> > > > Ben
> > > > 
> > > > --- In [EMAIL PROTECTED] <mailto:flexcoders%
40yahoogroups.com>
> > > ups.com,
> > > > "Tim Hoff" <TimHoff@> wrote:
> > > > >
> > > > > 
> > > > > Hey Ben,
> > > > > 
> > > > > In addition to setting the label, you have to set the 
selected
> > > property.
> > > > > 
> > > > > var q:QName = new QName
> > (DOCUMENT_METADATA_NAMESPACE, "PlanNumber");
> > > > > var r:QName = new QName(DOCUMENT_METADATA_NAMESPACE,
> > > > > "PlanNumberSelected");
> > > > > cb_planNumber.label = data[q];
> > > > > cb_planNumber.selected = data[r];
> > > > > 
> > > > > Depending on your data structure, PlanNumberSelected is 
the 
> > value
> > > field
> > > > > from the data.
> > > > > 
> > > > > -TH
> > > > > 
> > > > > --- In [EMAIL PROTECTED] <mailto:flexcoders%
> > 40yahoogroups.com>
> > > ups.com,
> > > > "ben.clinkinbeard"
> > > > > <ben.clinkinbeard@> wrote:
> > > > > >
> > > > > > Hello, I have seen this dicussed on here a bit but 
nothing 
> > seems
> > > to be
> > > > > > working for me. I have a DataGrid whose dataProvider 
> > property is
> > > bound
> > > > > > to an XMLList. One of the columns, however, uses an 
> > itemRenderer to
> > > > > > display a checkbox with a label. The label comes from 
the 
> > data item,
> > > > > > so this is what my itemRenderer component currently 
looks 
> > like:
> > > > > >
> > > > > > <?xml version="1.0" encoding="utf-8"?>
> > > > > > <mx:HBox xmlns:mx="http://www.adobe.
> > > <http://www.adobe.com/2006/mxml>
> > > > com/2006/mxml"
> > > > > > horizontalAlign="center" creationComplete="getLabel()">
> > > > > > <mx:Script>
> > > > > > <![CDATA[
> > > > > > import
> > > > > >
> > > > >
> > > >
> > > 
> > 
com.fmr.tests.PSA_Cairngorm.business.namespaces.DOCUMENT_METADATA_NAM
> > ESP\
> > > > > ACE;
> > > > > >
> > > > > > private function getLabel():void
> > > > > > {
> > > > > > use namespace DOCUMENT_METADATA_NAMESPACE;
> > > > > > var q:QName = new QName
> > (DOCUMENT_METADATA_NAMESPACE, "PlanNumber");
> > > > > > cb_planNumber.label = data[q];
> > > > > > }
> > > > > > ]]>
> > > > > > </mx:Script>
> > > > > > <mx:CheckBox id="cb_planNumber" />
> > > > > > </mx:HBox>
> > > > > >
> > > > > > The problem is that when the XMLList that is the 
> > dataProvider is
> > > > > > updated, the checkboxes' labels get updated correctly, 
but 
> > the
> > > > > > selected state of the checkboxes does not. So basically 
I 
> > need to
> > > > > > capture that event so that I can uncheck all of the 
> > checkboxes. A
> > > > > > 'labelChanged' event or something similar would be great 
but 
> > doesn't
> > > > > > seem to exist. What am I missing here?
> > > > > >
> > > > > > Thanks in advance,
> > > > > > Ben
> > > > > >
> > > > >
> > > >
> > >
> >
>







------------------------ Yahoo! Groups Sponsor --------------------~--> 
Great things are happening at Yahoo! Groups.  See the new email design.
http://us.click.yahoo.com/TISQkA/hOaOAA/yQLSAA/nhFolB/TM
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to