You could also have done
 
private function addFromTopDG():void {
    var obj:Object = ObjectUtil.copy(fromDG.selectedItem);
    delete obj.mx_internal_uid;
    (toDG.dataProvider as ArrayCollection).addItem(obj);
    obj = null; 
   }
 
We would auto-generate it for you.

 
________________________________

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Ju Aedis
Sent: Thursday, April 12, 2007 12:46 AM
To: [EMAIL PROTECTED]
Subject: Re: [flexcoders] mx_internal_uid Problem in Add Data



Alex:
Thanks,
I edited the code :
private function addFromTopDG():void {
    var obj:Object = ObjectUtil.copy(fromDG.selectedItem);
    obj.mx_internal_uid = UIDUtil.createUID();
    (toDG.dataProvider as ArrayCollection).addItem(obj);
    obj = null; 
   }
 
this way can change the uid,
& you said I can delete the uid before copy it ,can you give me an
example?thanks

 
12 Apr 2007 00:39:38 -0700, Alex Harui <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> >: 

        
        If they are truly the same data, you should prevent them from
being added twice.
         
        If they are clones/copies, then you can always delete the uid
before copying it.  However if you use strongly-typed classes instead of
dynamic objects you shouldn't have this problem provided you clone them
using ObjectUtil 
         
        -Alex

________________________________

        From: [EMAIL PROTECTED] <http://ups.com/>  [mailto:
flexcoders@ <mailto:flexcoders@> yahoogroups.com
<http://yahoogroups.com> ] On Behalf Of aedisju
        Sent: Wednesday, April 11, 2007 10:37 PM
        To: [EMAIL PROTECTED] ups.com <http://ups.com/> 
        Subject: [flexcoders] mx_internal_uid Problem in Add Data
        
         
        

        the problem is that when I add the selectedItem data from fromDG
to
        toDG twice or more.
        U can find the mx_internal_uids are the same value, It causes
problem
        that the DG thought that 
        they are the same object. Of course, I can't mousefocus in it. 
        
        Any One can help me?
        Thanks!
        
        Code:
        
        <?xml version="1.0" encoding="utf-8"?>
        <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> ">
        <mx:Script>
        <![CDATA[
        import mx.utils.ObjectUtil;
        import mx.controls.Alert;
        import mx.collections.ArrayCollection;
        [Bindable]
        public var dataArr:Array = [{label:"Red", data:"#FF0000"}, 
        {label:"Green", data:"#00FF00"},
        {label:"Blue", data:"#0000FF"}
        ];
        [Bindable]
        public var problemArr:Array = new Array();
        private var i:Number = 0;
        private function addFromTopDG():void { 
        //app_From_DG.selectedItem.label = ""+i++; //if you change the
        data, problem is still here
        (toDG.dataProvider as
ArrayCollection).addItem(fromDG.selectedItem);
        }
        ]]>
        </mx:Script>
        <mx:DataGrid id="fromDG" width="600" height="200" 
        dataProvider="{dataArr}">
        <mx:columns>
        <mx:Array>
        <mx:DataGridColumn width="300" dataField="mx_internal_uid"/>
        <mx:DataGridColumn dataField="label"/> 
        <mx:DataGridColumn dataField="data"/>
        </mx:Array>
        </mx:columns>
        </mx:DataGrid>
        <mx:Button label="Add from Top_DG" click="addFromTopDG()"/>
        <mx:DataGrid id="toDG" width="600" height="200" 
        dataProvider="{problemArr}">
        <mx:columns>
        <mx:Array>
        <mx:DataGridColumn width="300" dataField="mx_internal_uid"/>
        <mx:DataGridColumn dataField="label"/> 
        <mx:DataGridColumn dataField="data"/>
        </mx:Array>
        </mx:columns>
        </mx:DataGrid>
        </mx:Application>
        
        

        

        

        




-- 
Aedis.Ju--http://aedisju.blogspot.com/ 

 

Reply via email to