Re: Clearing List Control

2016-09-29 Thread Alex Harui
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"  wrote:

>Apparently this works,  But I don't understand why you just can't say the
>selectedIndicies are null or new Vector
>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
> wrote:
> 
>
> I'm stumped guys.  I must be missing something completely, ridiculously,
>easy.
>list.selectedIndices = new Vector.();
>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 :)
>
>
>   



Re: Clearing List Control

2016-09-29 Thread Kyle McKnight
Nevermind. I'm silly. I just realized what I sent lol. If it's null it'll
set it to a new empty Vector. Ignore me please :)


Kyle McKnight
Senior UI Engineer - Accesso
602.515.1444 (M)

On Thu, Sep 29, 2016 at 4:52 PM, Kyle McKnight  wrote:

> Did you try list.selectedIndices = []?
>
> The documentation says that the default value is []. So I looked at the
> source for List for selectedIndices setter. Looks like if value is null, it
> won't set the indices, so it won't get updated.
>
> if (value)
>  _proposedSelectedIndices = value;
> else
>  _proposedSelectedIndices = new Vector.();
>
>
>
>
> Kyle McKnight
> Senior UI Engineer - Accesso
> 602.515.1444 (M)
>
> On Thu, Sep 29, 2016 at 4:47 PM, Matthew Weir <
> mattcomm...@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
>> 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
>>  wrote:
>>
>>
>>  I'm stumped guys.  I must be missing something completely, ridiculously,
>> easy.
>> list.selectedIndices = new Vector.();
>> 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 :)
>>
>>
>>
>
>
>


Re: Clearing List Control

2016-09-29 Thread Kyle McKnight
Did you try list.selectedIndices = []?

The documentation says that the default value is []. So I looked at the
source for List for selectedIndices setter. Looks like if value is null, it
won't set the indices, so it won't get updated.

if (value)
 _proposedSelectedIndices = value;
else
 _proposedSelectedIndices = new Vector.();




Kyle McKnight
Senior UI Engineer - Accesso
602.515.1444 (M)

On Thu, Sep 29, 2016 at 4:47 PM, Matthew Weir  wrote:

> Apparently this works,  But I don't understand why you just can't say the
> selectedIndicies are null or new Vector
> 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
>  wrote:
>
>
>  I'm stumped guys.  I must be missing something completely, ridiculously,
> easy.
> list.selectedIndices = new Vector.();
> 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 :)
>
>
>


Re: Clearing List Control

2016-09-29 Thread Matthew Weir
Apparently this works,  But I don't understand why you just can't say the 
selectedIndicies are null or new Vector
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 
 wrote:
 

 I'm stumped guys.  I must be missing something completely, ridiculously, easy.
list.selectedIndices = new Vector.();
                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 :)


   

Clearing List Control

2016-09-29 Thread Matthew Weir
I'm stumped guys.  I must be missing something completely, ridiculously, easy.
list.selectedIndices = new Vector.();
                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 :)