Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I remove / clear items out of a list control in Flex?

I have a list control in Flex that has been data bound to an e4x xml object from an HTTPService.

I would now like to have a button that clears the list, how can I do this?

I have tried:


list.dataProvider = null;

which does not seem to work, I have also tried:


list.dataProvider = {};

which clears the items but leaves [object,object] as the first item in the list...

like image 452
mmattax Avatar asked Jan 21 '26 01:01

mmattax


2 Answers

Perhaps...

list.dataProvider = new Array();
like image 184
Matt W Avatar answered Jan 23 '26 05:01

Matt W


Setting the dataProvider to a new Array object will throw an error:

Implicit coercion of a value of type Array to an unrelated type fl.data:DataProvider.

Instead, you should use the removeAll() method provided by DataProvider:

list.dataProvider.removeAll();

This triggers a REMOVE_ALL event in the DataProvider which, in turn, will update your list.

like image 36
Christopher Inch Avatar answered Jan 23 '26 05:01

Christopher Inch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!