3 Replies Latest reply on Feb 11, 2011 6:58 AM by kosiara.87

    Loop Through Datagrid and Get Item Values at ItemRenderer

    AngeloAnolin

      Hi Everyone,

       

      If I set up my datagrid where the columns are defined by ItemRenderer, how do I loop through all the items and get the values for each column in the datagrid?

       

      My datagrid:

       

      <mx:DataGrid id="dgOutwardList"
             dataProvider="{_arrItems}"
             useRollOver="false"
             height="450"
             width="100%"
             verticalScrollPolicy="auto"
             sortableColumns="false"
             draggableColumns="false"
             resizableColumns="false">
          <mx:columns>
         
           <mx:DataGridColumn headerText="" dataField="itemNo" width="20"/>
          
           <mx:DataGridColumn headerText="Name of Passengers" dataField="testItem" width="200">
            <mx:itemRenderer>
             <mx:Component>
              <mx:TextInput width="100%" />
             </mx:Component>
            </mx:itemRenderer>
           </mx:DataGridColumn>
          
           <mx:DataGridColumn width="150">
            <mx:headerRenderer>
             <mx:Component>
              <mx:VBox verticalGap="2" horizontalScrollPolicy="off" verticalScrollPolicy="off">
               <mx:HBox horizontalAlign="center" width="100%">
                <mx:Label text="Relation To" horizontalCenter="true" />
               </mx:HBox>
               <mx:HBox horizontalAlign="center" width="100%">
                <mx:Label text="Requestor" horizontalCenter="true" />
               </mx:HBox>
              </mx:VBox>
             </mx:Component>
            </mx:headerRenderer>
            <mx:itemRenderer>
             <mx:Component>
              <mx:ComboBox dataProvider="{['Select', 'Self', 'Son', 'Daughter', 'Father', 'Mother', 'Husband', 'Wife', 'Brother', 'Sister', 'Father-In-Law', 'Mother-In-Law']}" />
             </mx:Component>
            </mx:itemRenderer>
           </mx:DataGridColumn>
          
           <mx:DataGridColumn width="150" >
            <mx:headerRenderer>
             <mx:Component>
              <mx:VBox horizontalScrollPolicy="off" verticalScrollPolicy="off" verticalGap="2">
               <mx:Box horizontalAlign="center" width="100%">
                <mx:Label text="Age" />
               </mx:Box>
               <mx:HBox horizontalAlign="center" width="100%" >
                <mx:Label text="Year" horizontalCenter="true" width="50" />
                <mx:Spacer width="10"/>
                <mx:Label text="Month" horizontalCenter="true" width="50" />
               </mx:HBox>
              </mx:VBox>
             </mx:Component>
            </mx:headerRenderer>
            <mx:itemRenderer>
             <mx:Component>
              <mx:HBox horizontalAlign="center" width="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off">
               <mx:NumericStepper id="nsOutwardAgeYear" minimum="0" maximum="200" stepSize="1" width="50" textAlign="center"/>
               <mx:Spacer width="5"/>
               <mx:NumericStepper id="nsOutwardAgeMonths" minimum="0" maximum="200" stepSize="1" width="50" textAlign="center"/>
              </mx:HBox>
             </mx:Component>
            </mx:itemRenderer>
           </mx:DataGridColumn>
          
           <mx:DataGridColumn width="150">
            <mx:headerRenderer>
             <mx:Component>
              <mx:VBox verticalGap="2" horizontalScrollPolicy="off" verticalScrollPolicy="off">
               <mx:HBox horizontalAlign="center" width="100%">
                <mx:Label text="Type of Bay Seat" horizontalCenter="true" />
               </mx:HBox>
               <mx:HBox horizontalAlign="center" width="100%">
                <mx:Label text="Required" horizontalCenter="true" />
               </mx:HBox>
              </mx:VBox>
             </mx:Component>
            </mx:headerRenderer>
            <mx:itemRenderer>
             <mx:Component>
              <mx:ComboBox dataProvider="{['Baby Seat Type', 'Up to 10 Kg.', 'Up to 18 Kg. (6 Mo. - 4 Yrs.)', 'Bolster Seat (15 Kg. up)']}" />
             </mx:Component>
            </mx:itemRenderer>
           </mx:DataGridColumn>
          </mx:columns>
         </mx:DataGrid>


      Appreciate your inputs. Thanks.