Here is my take on what you are trying to do...

Application:
<?xml version="1.0" encoding="utf-8"?>
<Application xmlns="http://www.adobe.com/2006/mxml";
   creationComplete="cc()" layout="horizontal">
   <Script>
     <![CDATA[
       import mx.events.ListEvent;
       import mx.collections.ArrayCollection;

       [Bindable] public var d:ArrayCollection = new ArrayCollection([]);
       private const ITEM_COUNT:int = 15;

       private function cc():void
       {
         for (var i:int = 0; i < ITEM_COUNT; i++)
         {
           var item:TestObject = new TestObject;
           item.label = "Item " + i;
           d.addItem(item);
         }
       }
     ]]>
   </Script>
   <AdvancedDataGrid id="list" dataProvider="{d}" height="100%">
     <columns>
       <AdvancedDataGridColumn dataField="label"
itemRenderer="MyItemRenderer"/>
     </columns>
   </AdvancedDataGrid>
</Application>

MyItemRenderer.as:
package
{
     import flash.events.MouseEvent;
     import mx.collections.ArrayCollection;
     import mx.controls.AdvancedDataGrid;
     import mx.controls.LinkButton;
     import mx.controls.dataGridClasses.DataGridListData;

     public class MyItemRenderer extends LinkButton
     {
         private var theData:Object;

         public function MyItemRenderer()
         {
             super();
         }

         override public function set data(value:Object):void
         {
             super.data = value;
             theData = value;
             if(value != null)
             {
                 label = value[DataGridListData(listData).dataField];
                 if(theData.highlighted)
                 {
                     setStyle("fontWeight", "bold");
                 }
                 else
                 {
                     setStyle("fontWeight", "normal");
                 }
                 addEventListener(MouseEvent.MOUSE_OVER,
changeDataProvider);
             }
         }

         private function changeDataProvider(event:MouseEvent):void
         {
             var dp:ArrayCollection = ((event.target as
MyItemRenderer).owner as AdvancedDataGrid).dataProvider as
ArrayCollection;
             var rowCount:int = 0;
             for each(var testObject:TestObject in dp)
             {
                 if((dp[rowCount] as TestObject).label == theData.label)
                 {
                     (((event.target as MyItemRenderer).owner as
AdvancedDataGrid).dataProvider[rowCount] as TestObject).highlighted =
true;
                 }
                 else
                 {
                     (((event.target as MyItemRenderer).owner as
AdvancedDataGrid).dataProvider[rowCount] as TestObject).highlighted =
false;
                 }
                 rowCount++;
             }
         }
     }
}


HTH



Steve


Reply via email to