How to remove / clear items from a list control in Flex?

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

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

I tried:


list.dataProvider = null;

which doesn't seem to work, I also tried:


list.dataProvider = {};

which clears the elements but leaves [object, object] as the first element in the list ...

+3
source share
2 answers

Maybe...

list.dataProvider = new Array();
+8
source

Installation dataProviderin a new object Arraywill result in an error:

Implicitly enforcing an Array value to an unrelated fl.data:DataProvider type.

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

list.dataProvider.removeAll();

REMOVE_ALL DataProvider, , , .

+5

All Articles