Skip navigation
Currently Being Moderated

Flex list has no selection color or rollover color after adding an item to it's dataprovider

Oct 27, 2011 9:09 AM

Tags: #list

Hi,

 

I have a basic list that uses an item renderer to display images.

 

If I add an item to the list, on a button click for example, the item gets added to the list perfectly fine but when i rollover/select this newly added item the highlight is not visibe and it actually stays on the list item that was previously selected?

 

Could anyone shed some light on this really, really anoying issue for me please?

 

Thanks

Flexchief

 
Replies
  • Currently Being Moderated
    Oct 27, 2011 9:34 AM   in reply to flexchief

    Please post a simple test case showing your issue. What version of Flex are you on?

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 27, 2011 10:39 AM   in reply to flexchief

    In MX List, if you are adding the same String or object instance, it will screw up the selection and highlighting because it uses UIDs to distinguish between items.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 27, 2011 9:50 PM   in reply to flexchief

    Use Spark List.  Or generate unique objects.  There isn’t too much utility to having an object occur twice in a dataprovider.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 27, 2011 10:07 PM   in reply to flexchief

    Thanks for the reply but do you know of any sort of workaround for this problem with UIDs?

     

    Assuming your dataProvider is filled with a list of strings:

     

    [Bindable]
    public var dataProvider:IList;
    
    
    private static function getListData(items:IList):ILIst
    {
              var source:Array = [];
              for each(var label:String in items)
              {
                        source.push( {label:label} );
              }
    
              return new ArrayCollection(source);
    }
    
    
    <mx:List dataProvider="{getListData(this.dataProvider)}" />
     
    |
    Mark as:
  • Currently Being Moderated
    Oct 28, 2011 2:46 PM   in reply to flexchief

    That is an easy fix..

     

    private static function getListData(items:IList):ILIst
    {
              var source:Array = [];
              for each(var item:Object in items)
              {
                      if(item is String)
                           source.push( {label:item} );
                      else
                            source.push(item);
              }
    
    
              return new ArrayCollection(source);
    }
    

     

    But I suppose disabling the selection color all together works too.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points