tags:

views:

399

answers:

3

Hello; I am a Java developer who tries Flex.

So my new problem is such:

I have a list component in Flex filled by objects got from Java (by binding dataprovider). I have put drag-drop support on list. Everything is good. But I wanted to have a reset function to reinitialize list, namely get back drag-dropped elements to the list.

I tried several thing on event handler of reset button but could not reinitialise the list data. For example:

public function resetList():void {
     trace("reset")
     listsrc.dataProvider = srv.getTerritories.lastResult
    }

"reset" is debugged but there is no change on list.

Thanks;

A: 

try listsrc.invalidateList();

TheBrain
no it did not work. no change on the list.
javanes
then you need to keep a copy of the array that you provide as dataProvider to the list. since when you drag them out, they will be removed from the source of the dataProvider, reasigning the same array to it won't do any good, since the elements are taken out.
TheBrain
A: 

I found it. In fact it is simple. I just said:

public function resetList():void {
        trace("reset")
        srv.getTerritories.send()
    }

Because is already binded; any change in data provider is directly reflected to list.

javanes
A: 

another way to do this is to have the control be bound to a arrayCollection that is bindable.

[Bindable]
var listDP:Array;

in mxml code

listsrc.dataProvider = listDP;

in actionScript whenever you are getting it from the server

listDP = srv.getTerritories.send();

By doing it this way you don't have to have your control instantiated before requesting data from the server.

AndrewB