When you set the highlighted property on your items, they are
dispatching PropertyChangeEvents. The collection they are in will
receive these PropertyChangeEvents and dispatch CollectionChangeEvents.
The AdvancedDataGrid will receive these and perform a visual update,
which appears to clear the rollover highlight.

To prevent the rollover highlight clearing you need to avoid dispatching
PropertyChangeEvents when you update the hightlighted property. Which
means you need to use a custom event in your binding (see below). This
should fix the choppiness without breaking the binding, although you
might want to rethink this whole approach: When you select an item in a
datagrid it sets the selectedItem property; it doesn't update the
underlying data items. Why not follow this pattern for tracking which
item is rolled over?

package
{
    import flash.events.EventDispatcher;

  public class TestObject extends EventDispatcher
  {
    [Bindable]
    public var label:String;

    private var _highlighted:Boolean;

    public function get highlighted() : Boolean
    {
        return _highlighted;
    }

    [Bindable( event = "highlightedChange" )]
    public function set highlighted( highlighted : Boolean ) : void
    {
        _highlighted = highlighted;
        dispatchEvent( new Event( "highlightedChange" ) );
    }
  }
}

Pan Troglodytes wrote:
> 1) Yes, this works fine, for the display portion only.  It doesn't address
> the actual problem of needing to set a flag in the data that indicates it is
> the currently highlighted one, that flag being also used by other things
> that bind to the data that don't want to know about UI details like the
> grid.  In this case, I had a number of chart listeners that would toggle
> series on/off depending on which one was highlighted in the grid.
>
> 2) There is no commitProperties on AdvancedDataGridItemRenderer.  Perhaps
> you meant validateProperties.  In this example, it gets called only when the
> grid is first displayed and not when any item is highlighted/de-highlighted
> or selected/de-selected.
>
> 3) Yes, the styleFunction does get called when the highlighted object
> changes.  But if you move the code to set data.highlighted there, you get
> the same result!  It just seems like anything that changes this bound
> variable on every repaint of the cell is doomed to break the rollover
> highlight.
>
> On Tue, Jun 9, 2009 at 11:49 AM, Amy <amyblankens...@bellsouth.net> wrote:
>
>   
>> --- In flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com>, Pan
>> Troglodytes <chimpathe...@...> wrote:
>>     
>>> That was a good idea and it does get rid of the arraycollection walking.
>>> But I get the SAME problem with the grid losing highlighting when I did
>>>       
>> it
>>     
>>> using AdvancedGridItemRenderer, thought the symptoms are slightly
>>>       
>> different:
>>
>> Personally, I'd do one of two things:
>>
>> 1) Just look to see if the current item is the highlighted item in the
>> styleFunction
>>
>> -or-
>>
>> 2) Override commitProperties instead of validateNow().
>>
>> I'd also be tempted to investigate whether the styleFunction gets called
>> when the highlighted object changes.
>>
>> HTH;
>>
>> Amy
>>
>>  
>>
>>     
>
>
>
>   



Reply via email to