for(var i:Number=0; i < 4; i++){
                                        var child:comp_DG = new
comp_DG();
                                        myTab.addChild(child);
                                        child.arrColInfo = arrCol;
                                        child.myLBL.text = ''+i;
                                        child.label=''+i;
                                }


If i understood correctly your problem - when changing anything on any
one of the datagrid, also replicates the same change for rest og the
three datagrids and that is the problem ..... Correct?

In that case it might be because you are assigning same instance of
arrCol to every child object. You may consider creating clones of
arrCol object and assign to eacg child.arrColInfo.


Regards,
manik



On Sep 13, 4:52 am, flex <[email protected]> wrote:
> hi friends
> i am run time creating instance of 1 component and assigning arraycol
> data to that component arracol.
> When i'm changing value in 1st instance it also giving me change in
> all \.
>
> See the example below and click on 'Check Change' button where i'm
> alert changed value for 1st 2 instances where it gives me same even i
> changed 1st instance checkbox.
>
> main.mxml
>
> <?xml version="1.0" encoding="utf-8"?>
> <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009";
>                                            
> xmlns:s="library://ns.adobe.com/flex/spark"
>                                            
> xmlns:mx="library://ns.adobe.com/flex/mx"
>
> creationComplete="windowedapplication1_creationCompleteHandler(event)">
>         <s:layout>
>                 <s:VerticalLayout/>
>         </s:layout>
>
>         <fx:Script>
>                 <![CDATA[
>                         import mx.controls.Alert;
>                         import mx.events.FlexEvent;
>
>                         protected function
> windowedapplication1_creationCompleteHandler(event:FlexEvent):void
>                         {
>                                 for(var i:Number=0; i < 4; i++){
>                                         var child:comp_DG = new comp_DG();
>                                         myTab.addChild(child);
>                                         child.arrColInfo = arrCol;
>                                         child.myLBL.text = ''+i;
>                                         child.label=''+i;
>                                 }
>                         }
>
>                         protected function 
> button1_clickHandler(event:MouseEvent):void
>                         {
>                                 var child:comp_DG = myTab.getItemAt(0) as 
> comp_DG;
>                                 var child2:comp_DG =  myTab.getItemAt(1) as 
> comp_DG;
>
>                                 
> Alert.show(''+child.arrColInfo.getItemAt(0).selected+' :
> '+child2.arrColInfo.getItemAt(0).selected);
>                                 //Alert.show(''+child.myLBL.text+' : 
> '+child2.myLBL.text);
>                         }
>
>                 ]]>
>         </fx:Script>
>         <fx:Declarations>
>                 <!-- Place non-visual elements (e.g., services, value 
> objects) here
> -->
>                 <s:ArrayCollection id="arrCol">
>                         <fx:Object label='1' selected="false" />
>                         <fx:Object label='2' selected="false" />
>                         <fx:Object label='3' selected="false" />
>                         <fx:Object label='4' selected="false" />
>                         <fx:Object label='5' selected="false" />
>                         <fx:Object label='6' selected="false" />
>                         <fx:Object label='7' selected="false" />
>                         <fx:Object label='8' selected="false" />
>                         <fx:Object label='8' selected="false" />
>                         <fx:Object label='10' selected="false" />
>                 </s:ArrayCollection>
>         </fx:Declarations>
>
>         <mx:TabNavigator id="myTab" width="100%" height="100%" >
>         </mx:TabNavigator>
>         <s:Button label="Check Change" click="button1_clickHandler(event)" />
> </s:WindowedApplication>
>
> comp_DG.mxml
> <?xml version="1.0" encoding="utf-8"?>
> <mx:HBox xmlns:fx="http://ns.adobe.com/mxml/2009";
>                  xmlns:s="library://ns.adobe.com/flex/spark"
>                  xmlns:mx="library://ns.adobe.com/flex/mx" width="400" 
> height="300"
>                  creationComplete="group1_creationCompleteHandler(event)">
>
>         <fx:Script>
>                 <![CDATA[
>                         import mx.collections.ArrayCollection;
>                         import mx.events.FlexEvent;
>                         public var arrColInfo:ArrayCollection = new 
> ArrayCollection();
>
>                         protected function
> group1_creationCompleteHandler(event:FlexEvent):void
>                         {
>                                 dg.dataProvider = arrColInfo;
>                         }
>
>                 ]]>
>         </fx:Script>
>         <fx:Declarations>
>                 <!-- Place non-visual elements (e.g., services, value 
> objects) here
> -->
>         </fx:Declarations>
>         <s:VGroup >
>                 <s:TextInput id="myLBL" />
>
>                 <mx:DataGrid id="dg" width="100%" height="300"
>                                          >
>                         <mx:columns>
>                                 <mx:DataGridColumn headerText="Select"
>                                                                    width="50">
>                                         <mx:itemRenderer>
>                                                 <fx:Component>
>                                                         <mx:HBox 
> horizontalAlign="center"
> verticalAlign="middle">
>                                                                 <s:CheckBox 
> id="chb" selected="{data.selected}"
>                                                                               
>           change="data.selected=chb.selected;"/>
>                                                         </mx:HBox>
>                                                 </fx:Component>
>                                         </mx:itemRenderer>
>                                 </mx:DataGridColumn>
>
>                                 <mx:DataGridColumn headerText="Label"  
> dataField="label"
>                                                                    
> width="300" />
>                         </mx:columns>
>                 </mx:DataGrid>
>
>         </s:VGroup>
> </mx:HBox>
>
> is any way there to get changes made by user in datagrid?
> thanks you.

-- 
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en.

Reply via email to