Each item in a collection must have a unique id.  You are adding the
same object several times so they'll all have the same UID.  You will
need to make copies or new instances before adding to the collection.

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of learner
Sent: Wednesday, November 28, 2007 10:35 PM
To: [email protected]; Flex India Community
Subject: [flexcoders] what is wrong with the following code: datagrid
ItemRenderer



In the following code : 
the last item remain selected.. can somebody help me to debug this. this
is really driving me crazy..

<?xml version="1.0"?>
<mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " creationComplete="init()">
    <mx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            [Bindable]
            public var  initDG:ArrayCollection = new ArrayCollection() 
            public function init(){
                var a:Object = new Object();
                 a.Artist = 'Pavement';
                 a.Album = 'Slanted and Enchanted'
                  a.Price=11.99
                 a.Cover='slanted.jpg'
                 initDG.addItemAt(a,0)
                 initDG.addItemAt(a,1)
                 initDG.addItemAt(a,2)
                 initDG.addItemAt (a,3)
                 myGrid.dataProvider = initDG
            }
               
                    
            
        ]]>
    </mx:Script>

    <mx:DataGrid id="myGrid" dataProvider="{initDG}" 
            variableRowHeight="true">   
        <mx:columns>
              
                <mx:DataGridColumn dataField="Album">
                    <mx:itemRenderer> 
                        <mx:Component>
                        <mx:Button label="{data.Album}"/>
                           mx:Component>
                    </mx:itemRenderer>
                </mx:DataGridColumn>    
               
        </mx:columns>       
    </mx:DataGrid>      
</mx:Application>

Thanks in advance 
Regards



 

Reply via email to