Thanks Tim. That's the code I'd seen before. (but was too lazy to go
look for <g>)

Here's how I accomplished it. A bit different, but it works. Any
comments on this would be appreciated.

Kenny

CODE
======================

public function init():void {         
                addEventListener("dataChange", handleDataChanged);
            } 

private function handleDataChanged(event:Event):void
{
        if (data.fn == 'Live')
        {
                theButton.visible = false;      
        }
        else
        {
                theButton.visible = true;
        }
}






--- In [email protected], "Tim Hoff" <[EMAIL PROTECTED]> wrote:
>
> 
> Hi Kenny,
> 
> Just for a little more background info that others may find beneficial. 
> You can think of the data object as a single record (or row) in the
> DataGrid's dataProvider (dataset).  Every column's itemRenderer in a
> DataGrid has access to all of the fields in the record (data object);
> regardless of the dataField that is set.  However, since itemRenderers
> are recycled, you have to perform any conditional logic in the
> itemRenderer's set data function.  This ensures that when the data is
> changed, that the itemRenderer will be refreshed with the appropriate
> state.  Inside the RollOverButton itemRenderer, you'll have to override
> the set data method in script:
> 
> override public function set data(value:Object):void
> {
>      super.data = value;
> 
> 
> 
>      if (data != null)
>      {
>         this.visible = (data.fn == "showMe" ? true : false);
>      }
> 
> super.invalidateDisplayList();
> 
> }
> 
> Hope that this helps.
> 
> Cheers,
> -TH
> 
> --- In [email protected], "Kenny" <kennysphone@> wrote:
> >
> > I figured it out!!
> >
> > Thanks again for the help. :o)
> >
> > Kenny
> >
> >
> > --- In [email protected], "Kenny" kennysphone@ wrote:
> > >
> > > Oh! Now see, I knew it would be something simple. :o)
> > >
> > > Ok, so that helped me with another problem I was having elsewhere
> too,
> > > so double thanks for that one!
> > >
> > > I have read about the render handlers not keeping state, but I'm not
> > > sure how to handle this situation. How can I set it for each case,
> as
> > > you've instructed? I'm sure I've seen it somewhere before, but
> > > honestly, it's quicker for me to ask here than to go look around the
> > > web for it. ;o)
> > >
> > > Thanks again!
> > >
> > > Kenny
> > >
> > > --- In [email protected], "Tracy Spratt" <tspratt@> wrote:
> > > >
> > > > Should be data.fn;
> > > >
> > > >
> > > >
> > > > Note, you must set this for every case, ie, always set the
> > visibility on
> > > > data change. Renderers are recycled and will not keep any state.
> > > >
> > > >
> > > >
> > > > Tracy
> > > >
> > > >
> > > >
> > > > ________________________________
> > > >
> > > > From: [email protected]
> > [mailto:[EMAIL PROTECTED] On
> > > > Behalf Of Kenny
> > > > Sent: Friday, May 23, 2008 11:24 AM
> > > > To: [email protected]
> > > > Subject: [flexcoders] Question regarding DataGrid
> > > >
> > > >
> > > >
> > > > Hello.
> > > >
> > > > In the following code, I would like to be able to reference the
> data
> > > > field called "fn" from within the item renderer for the last
> column,
> > > > which contains the RollOverButton.
> > > >
> > > > Can someone tell me how I can do this?
> > > >
> > > > What I want to do is have the button be visible in some cases, but
> not
> > > > others.
> > > >
> > > > Thanks!
> > > >
> > > > Kenny
> > > >
> > > > CODE BELOW
> > > > ==================================
> > > >
> > > > <mx:DataGrid id="dgMediaHistory"
> > > > x="27"
> > > > y="59"
> > > > width="380"
> > > > height="339"
> > > >
> dataProvider="{svcGetMediaHistory.lastResult.dataset.mediahistory}"
> > > > resizableColumns="false"
> > > > allowMultipleSelection="false"
> > > > allowDragSelection="false"
> > > > draggableColumns="false"
> > > > change="historyChangeHandler()">
> > > > <mx:columns>
> > > > <mx:DataGridColumn headerText="Msg" dataField="fn" width="85"/>
> > > > <mx:DataGridColumn headerText="Date" dataField="whenplayed"
> > > > width="140"/>
> > > > <mx:DataGridColumn headerText="" width="30">
> > > > <mx:itemRenderer>
> > > > <mx:Component>
> > > > <comp:RollOverButton width="20" height="20"
> > > > upImage="{outerDocument.playImageUp}"
> > > > overImage="{outerDocument.playImageOver}"
> > > > downImage="{outerDocument.playImageDown}"
> > > > click="outerDocument.playMedia()"/>
> > > > </mx:Component>
> > > > </mx:itemRenderer>
> > > > </mx:DataGridColumn>
> > > > </mx:columns>
> > > > </mx:DataGrid>
> > > >
> > >
> >
>


Reply via email to