flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Harui <aha...@adobe.com>
Subject Re: Clearing List Control
Date Thu, 29 Sep 2016 21:07:05 GMT
I don't know if you are referring to MX List or Spark List, but it may not
matter.  IIRC, there is logic in the List classes to recalculate selection
when the data provider is changed.  For sure, most of Flex uses an
invalidation/validation model.  This allows you to set a property multiple
times without it actually having an effect on the component.  I'd bet if
you sprinkled a few more validateNow() calls in there you'd get different
results.

IOW, if at some point:

  list.dataProvider = ac;

Later if you just do:
  list.dataProvider = null;
  list.dataProvider = ac;

It may not have an affect since the change to DP will not be processed
until later (or on validateNow()).

By making a deep copy of the original DP, you are changing the DP and the
UID of its items to something different which might trigger the change
detection logic and also result in different behavior.


HTH,
-Alex

On 9/29/16, 1:47 PM, "Matthew Weir" <mattcommark@yahoo.com.INVALID> wrote:

>Apparently this works,  But I don't understand why you just can't say the
>selectedIndicies are null or new Vector<int>
>var ac:ArrayCollection = new
>ArrayCollection(ObjectUtil.copy((list.dataProvider as
>ArrayCollection).source) as Array);
>ac.refresh();list.dataProvider = ac;
>
>    On Thursday, September 29, 2016 4:31 PM, Matthew Weir
><mattcommark@yahoo.com.INVALID> wrote:
> 
>
> I'm stumped guys.  I must be missing something completely, ridiculously,
>easy.
>list.selectedIndices = new Vector.<int>();
>                var ac:ArrayCollection = list.dataProvider as
>ArrayCollection;
>                list.dataProvider = null;
>                ac.refresh();
>                list.selectedIndices = null;
>                list.selectedIndex = -1;
>                list.dataProvider = ac;
>                list.invalidateDisplayList();
>                list.validateNow()
>Still shows selected items.
>Help!  Please :)
>
>
>   

Mime
View raw message