If your renderer implements the IDropInListItemRenderer (something like
that), you can access the dataProvider (or get the dataProvider from the
model)  then you can use getChildIndex() for a collection or childIndex() in
xml to get the item index.  If that index equals the dataProvider.length -
1, it is the last item.

 

I have used this technique to dynamically number the lines in a DataGrid.
That example is www.cflex.net <http://www.cflex.net/>  I believe.

 

Tracy Spratt,

Lariat Services, development services available

  _____  

From: [email protected] [mailto:[email protected]] On
Behalf Of Matthew
Sent: Wednesday, January 06, 2010 3:22 PM
To: [email protected]
Subject: [SPAM] [flexcoders] Re: Is my ItemRenderer on the last Row of data?

 

  

Very nice solution, Valdhor, thank you. I do, however, need it for the very
last row of data (visible or non-visible). 

In the meantime, I've added an extra property to my data that will allow me
to get what I need. So, instead of figuring out what label to put on a
button by deciphering whether the renderer is rendering the last row of
data, I just use a new 'label' property. 

Maybe a bit hackish, but it works. 

Thank you for your help. 

Matt

--- In flexcod...@yahoogro <mailto:flexcoders%40yahoogroups.com> ups.com,
"valdhor" <valdhorli...@...> wrote:
>
> That kinda depends on what you mean by the "last row of data". If you
> mean the last visible row (Which is the last row rendered - the renderer
> is only called for visible data) then you can try this...
> 
> package
> {
> import mx.collections.ArrayCollection;
> import mx.controls.*;
> import mx.controls.dataGridClasses.DataGridListData;
> 
> public class myRenderer extends Text
> {
> public function myRenderer()
> {
> super();
> }
> 
> override public function set data(value:Object):void
> {
> super.data = value;
> if(value != null)
> {
> text = value[DataGridListData(listData).dataField];
> if(listData.rowIndex == (owner as DataGrid).rowCount -
> 1)
> {
> trace("Rendering the last row");
> }
> }
> }
> }
> }
> --- In flexcod...@yahoogro <mailto:flexcoders%40yahoogroups.com> ups.com,
"Matthew" <fumeng5@> wrote:
> >
> > Hi,
> >
> > I know the answer to this question before asking it but hopefully
> someone has a found a way to do this.
> >
> > Is there a way to know (in my override of set data() method) whether
> my item renderer is rendering the last row of data?
> >
> > thanks for any help on this one,
> >
> > matt
> >
>



Reply via email to