Make sure your item renderer implements IDropInListItemRenderer
Define a listData getter/setter, which, when set by the component using the 
item renderer, will contain the index you need.

http://livedocs.adobe.com/flex/201/langref/mx/controls/listClasses/IDropInListItemRenderer.html
http://livedocs.adobe.com/flex/201/langref/mx/controls/listClasses/BaseListData.html

If you're writing the item renderer in MXML and the base class does not 
implement IDropInListItemRenderer, you can do the following:

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml";
 implements="mx.controls.listClasses.IDropInListItemRenderer"
 >

 <mx:Script>
  <![CDATA[

   import mx.controls.listClasses.BaseListData;

   // Internal variable for the listData property value.
   private var _listData:BaseListData;

   [Bindable("dataChange")]
   public function get listData():BaseListData {
    return _listData;
   }
   public function set listData(value:BaseListData):void {
    _listData = value;
   }

</mx:Canvas>

You can then use _listData.columnIndex, _listData.rowIndex


And, if you haven't already, read Alex's article about DataGrid/List item 
renderers:
http://blogs.adobe.com/aharui/2007/03/

regards,
Muzak

----- Original Message ----- 
From: "learner" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, November 26, 2007 8:31 AM
Subject: [flexcoders] Index of item in list


>I am using a list control and trying to give a alternate styles to it.
> (not just alternate colors).
> Hence I want to know the  index at which the current Item is going..
>
> Is there any way to know the instance of item renderer  it's
> currentIndex in List?
>
> Something like this :
>
> <mx:List itemRenderer = "myItem" dataProvider ={p}/>
>
>
> comp myItem :
>
> [Bindable] index:Number // index in the list.
>
> Thanks in advance
> Regards
> PS
> 



--
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/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> 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