In the following code, drag %26amp; drop is set to copy objects, but when more than one instance of an item exists, only the last item (highest data provider index) item can be selected. Any idea why this is happening, and how to correct this?
%26lt;?xml version=''1.0''?%26gt;
%26lt;mx:Application xmlns:mx=''http://www.adobe.com/2006/mxml''
?creationComplete=''init();''%26gt;
?%26lt;mx:Script%26gt;
?%26lt;![CDATA[
?import mx.collections.ArrayCollection;
?
?[Bindable] private var srcAC:ArrayCollection = new ArrayCollection();
?[Bindable] private var destAC:ArrayCollection = new ArrayCollection();
?private function init():void{
?srcAC = new ArrayCollection(['Fish', 'Meat', 'Chicken']);
?destAC = new ArrayCollection();
?}?
?
?private function displayData():void{
?trace(''****************************************'');
?trace(''menuList dataProvider:'');
?for each(var srcItem:Object in srcAC){
?trace(''\t'' + srcItem.toString());
?}
?trace(''----------------------------------------'');
?trace(''orderList dataProvider:'');
?for each(var destItem:Object in destAC){
?trace(''\t'' + destItem.toString());
?}
?}
?]]%26gt;
?%26lt;/mx:Script%26gt;
?%26lt;mx:HBox%26gt;
?%26lt;mx:VBox%26gt;
?%26lt;mx:Label text=''Today's Menu'' fontWeight=''bold'' fontSize=''14''/%26gt;
?%26lt;mx:List id=''menuList'' width=''200'' dataProvider=''{srcAC}''
?dragEnabled=''true'' dropEnabled=''true'' dragMoveEnabled=''false''
?allowMultipleSelection=''true'' fontSize=''14''/%26gt;
?%26lt;/mx:VBox%26gt;
?%26lt;mx:VBox%26gt;
?%26lt;mx:Label text=''Your Order'' fontWeight=''bold'' fontSize=''14''/%26gt;
?%26lt;mx:List id=''orderList'' width=''200'' dataProvider=''{destAC}''
?dragEnabled=''true'' dropEnabled=''true'' dragMoveEnabled=''false''
?allowMultipleSelection=''true'' fontSize=''14''/%26gt;
?%26lt;/mx:VBox%26gt;
?%26lt;/mx:HBox%26gt;
?%26lt;mx:Button id=''b1'' label=''Reset Order'' click=''init();''/%26gt;
?%26lt;mx:Button label=''Display Data Providers'' click=''displayData();''/%26gt;
%26lt;/mx:Application%26gt;
You know, this is exactly the kind of behavior I've seen before in a Datagrid when there's duplicates present.?You can only interact with the last ''row'' for the object.
It's definitely something I'm interested in finding out more about.?The solution to the problem in my case was to simply eliminate the duplicates.
(They were a server-side bug due to our crummy ORM framework which I don't like too much...)
I may try looking into this a little myself.?I'm curious how these lists are differentiating items.?It's almost like an ''equals'' or similar type of comparison method needs to be implemented on the items so the Flex list seems them as unique items, if you're familar with Java at all.
Strange Problem Drag %26 Drop Between...Hey Alex, where are you? You can surely shed some light on this?
bump
Hello
Actually I have also face this problem in one of my appliocation so have done some work arround for that.
If we use object of ArrayCollection as 'key-value' (like- {label:'Fish'} ) pair than it work fine.
srcAC = new ArrayCollection([ {label:'Fish'},{label:'Meat'},{label:'Chicken'}]);
In case of
srcAC = new ArrayCollection(['Fish', 'Meat', 'Chicken']);
If we drop same item two times than list is not identify unique item of the list
and if we use objet like- {label:'Fish'} than every item is unique for list.
I m not sure this is right or not but it works fine.
Also we need to set 'labelField' of list as per object.
With Regards
Virat Patel
Thanks very much, that is helpful, but I'm still wondering why this does not just work the way I'm doing it. I'm just adding to the data provider of the List.
Alex???
No comments:
Post a Comment