I'm trying to do something that I thought was trivial but has become
increasingly difficult. When I mouse over a row (not a cell or
specific item renderer), I want to force a style on a specific columns
itemRenderer. So I have a custom itemRenderer and custom Datagrid so I
can keep track of the highlighted row and change my styles. The styles
are taking, but the highlight selection bar isn't showing anymore (or
if it does, it's VERY briefly). Ideas?

Here's the code, tried to clean it up as good as I can

==== CustomDatagrid ====

package {

 import mx.controls.DataGrid;

 public class CustomDataGrid extends DataGrid {

       public function CustomDataGrid() {
               super();
       }

       public var highlightedRow:Number;

 }


====ComputedLinkRenderer.as====

package {

   import CustomDataGrid;

   public class ComputedLinkRenderer extends Label
   {
       // Define the constructor and set properties.
       public function ComputedLinkRenderer() {
           super();
       }


       // Override the set method for the data property.
       override public function set data(value:Object):void {
           super.data = value;
           text="Some Cool Restaurant Name"; // so you see something
           if(listData) {
             var dg:CustomDataGrid = (listData.owner) as CustomDataGrid;
             if(dg.highlightedRow == listData.rowIndex ||
dg.selectedIndex == listData.rowIndex-1) {
               setStyle("color",0x0000FF);
               setStyle("textDecoration","underline");
             } else {
               setStyle("color",0x000000);
               setStyle("textDecoration","none");
             }
           }
       }
   }
}


====Implementation of CustomDataGrid ====
           private function onRollOver(event:ListEvent):void {
                   //if mouse is moving on the same line, don't do anything.
                   if(lastRollOverIndex != event.rowIndex) {

                     lastRollOverIndex = event.rowIndex;
                     grdDashboard.highlightedRow = event.rowIndex;

grdDashboard.dataProvider.itemUpdated(dp[event.rowIndex-1]);
                   }

                 }

 <custom:CustomDataGrid id="grdDashboard" dataprovider="{dp}"
              itemRollOver="onRollOver(event)"
 <custom:columns>
     <mx:DataGridColumn           headerText="Applicant"
                                  itemRenderer="ComputedLinkRenderer"/>
   </custom:columns>
 </custom:CustomDataGrid>


It's definately the itemUpdated that's causing it, but I've tried
multiple different iterations of this idea (extending
mouseOver/mouseOut in ListBase, extending drawItem, etc). Is there an
easier solution to this idea or is there just something I can do to
get my highlightbar to come back?

Any help would be great,
Jon M

Reply via email to