5 Replies Latest reply on Feb 4, 2011 12:47 AM by BhaskerChari

    how to access component id between two item render

    Magesh R

      HI Friends,

       

      In my application ,i am using mx Data Grid,i have using two headers in my grid.one header have item render,another header have anthor item render.in my case i want the second header item render to access first header component id..

       

      Please Any one help to me...

       

       

      example

       

      <mx:DataGridColumn id="col4" headerText="Active" width="45">
             
              <mx:itemRenderer>
              
               <fx:Component>
               
                <mx:HBox>
                
                 <fx:Script>
                  <![CDATA[
                   import mx.collections.ArrayCollection;
                   override public function set data(value:Object):void
                   {
                    super.data = value;
                    if(data.isActive==1)
                    {
                     chkbox_active.selected=true;
                    }
                    else
                    {
                     chkbox_active.selected=false;
                    }
                   }
                  ]]>
                 </fx:Script>
                
                 <mx:CheckBox id="chkbox_active"/>
               
                </mx:HBox>
              
               </fx:Component>
             
              </mx:itemRenderer>
            
             </mx:DataGridColumn>
            
      <mx:DataGridColumn id="col5" headerText="Indexed" width="55">
             
              <mx:itemRenderer>
              
               <fx:Component>
               
                <mx:HBox>
                
                 <fx:Script>
                  <![CDATA[
                   override public function set data(value:Object):void
                   {
                    super.data = value;
                     if(data.isIndexed==1)
                    {
                     chkbox_indexed.selected=true;
                    }
                    else
                    {
                     chkbox_indexed.selected=false;
                    }
                   }
                   function Change_Grd_chbox_Active(event):void
                   {             
                    outerDocument.Global_ch_active=chkbox_active; //  Error Came ie  Access of undefined property chkbox_active
                     }
                  ]]>
                 </fx:Script>
                
                 <mx:CheckBox id="chkbox_indexed" click="Change_Grd_chbox_Active(event);"/>
               
                </mx:HBox>
              
               </fx:Component>
             
              </mx:itemRenderer>
            
             </mx:DataGridColumn>

       

       

       

       

      Thanks,

      Magesh R.

        • 1. Re: how to access component id between two item render
          BhaskerChari Level 4

          HI Magesh,

           

          Why you are trying to assign the check box component to Global_ch_active.?? What you are actually trying to accomplish..??

           

           

          Thanks,

          Bhasker

          1 person found this helpful
          • 2. Re: how to access component id between two item render
            Magesh R Level 1

            Hi friend,

             

            Because of i if select the check box specfic row  then corresponding the same row of  another header component will be hide ie( example: another check box   of first item render)...

             

             

             

            Thanks,

            Magesh R.

            • 3. Re: how to access component id between two item render
              BhaskerChari Level 4

              What you are doing is not the ideal way of doing it...instead what you try to do is ...get the index of the row checkbox clicked and based on the index change the property of that particular row in the other component dataprovider so that it is hided.

               

              Say in comp1 you clicked on 5th row so index is 4

               

              So in your comp2 itemRenderer...in dataProvider change the property to hide...

               

              dataProvider2.getItemAt(4).is_active = false;

               

              <mx:Check visible="{data.is_active}" />

               

              Can you post your total code so that it will be clear...

               

              Thanks,

              Bhasker

              • 4. Re: how to access component id between two item render
                Magesh R Level 1

                Hi Friend,

                 

                please help to me...

                 

                Code:

                 

                <mx:DataGrid  id="dg_profile_groups" dataProvider="{first}" width="940" color="#000000"
                          alternatingItemColors="[#FFFFFF,#A9A9A9]" verticalScrollPolicy="on" itemClick="item_click(event)">
                     
                      <mx:columns>      
                      
                       <mx:DataGridColumn id="col5" headerText="Indexed" width="55">
                       
                        <mx:itemRenderer>
                        
                         <fx:Component>
                         
                          <mx:HBox>
                          
                           <fx:Script>
                            <![CDATA[
                             override public function set data(value:Object):void
                             {
                              super.data = value;
                              outerDocument.chk_active=chkbox_indexed;
                              if(data.isIndexed==1)
                              {
                               chkbox_indexed.selected=true;
                              }
                              else
                              {
                               chkbox_indexed.selected=false;
                              }
                             }
                             function Change_Grd_chbox_Active(event):void
                             {             
                            // Here i want to hide combo box of next header component  in same index (if i select 3rd check box means ,the 3rd combo will be hide..how to do..)

                             }
                            ]]>
                           </fx:Script>
                          
                           <mx:CheckBox id="chkbox_indexed" click="Change_Grd_chbox_Active(event);"/>
                         
                          </mx:HBox>
                        
                         </fx:Component>
                       
                        </mx:itemRenderer>
                      
                       </mx:DataGridColumn>
                      
                       <mx:DataGridColumn id="col6" headerText="Data Type" width="70">
                       
                        <mx:itemRenderer>
                        
                         <fx:Component>
                         
                          <mx:HBox>
                          
                           <fx:Script>
                            <![CDATA[
                             import mx.collections.ArrayCollection;
                             [Bindable]
                             override public function set data(value:Object):void
                             {            
                             
                              
                              super.data = value;
                             
                              if(data.isIndexed==1)
                              {
                              
                               if(data.default_datatype==4)
                               {
                                cbox_datatype.selectedIndex=1;
                               }
                               else if(data.default_datatype==12)
                               {
                                cbox_datatype.selectedIndex=2;
                               }
                               else
                               {
                                cbox_datatype.selectedIndex=0;
                               }
                              
                               cbox_datatype.visible=true;
                               cbox_datatype.includeInLayout=true;
                              }
                              else
                              {
                               cbox_datatype.includeInLayout=false;
                               cbox_datatype.visible=false;
                              }
                             
                             }
                            ]]>
                           </fx:Script>
                          
                           <mx:ComboBox id="cbox_datatype" dataProvider="{outerDocument.cbox_array}" labelField="data"
                               visible="false" includeInLayout="false" width="70" />
                          </mx:HBox>
                        
                         </fx:Component>
                       
                        </mx:itemRenderer>
                      
                       </mx:DataGridColumn>      
                                      
                      </mx:columns>
                     
                     </mx:DataGrid>

                • 5. Re: how to access component id between two item render
                  BhaskerChari Level 4

                  Hi Magesh,

                   

                  It would be better to help you if you could post your total code with out any dependencies.

                   

                  Thanks,

                  Bhasker