0 Replies Latest reply on Jun 5, 2010 6:54 PM by mazrit

    Using setFocus in a Repeater

    mazrit

      I am currently using a Repeater for bulk submissions and have run into a problem. Any idea how I reset focus on on newly created text field in a repeater  row?

       

      My Repeater is made up of gridrows. Each gridrow holds multiple text inputs as well as a link button that kicks off my addRow event. Here's a sample of the code:

       

      <mx:Grid id="params" width="100%" height="100%" >
                  <mx:Repeater id="paramRepeater" dataProvider="{drivers}"  >
                      <mx:GridRow>
                      <mx:GridItem>
                              <mx:TextInput id="txtFirst" text="{paramRepeater.currentItem.firstTextField}" change="paramValueChangeFirst(event)" />
                      </mx:GridItem>
                      <mx:GridItem>
                              <mx:TextInput id="txtSecond" text="{paramRepeater.currentItem.secondTextField}" change="paramValueChangeSecond(event)" />
                      </mx:GridItem>
                      <mx:GridItem>
                              <mx:TextInput id="txtThird" text="{paramRepeater.currentItem.thirdTextField}" change="paramValueChangeThird(event)"/>
                      </mx:GridItem>

                     <mx:GridItem>
                              <mx:LinkButton icon="../images/add.png')" click="addRow(event)" styleName="linkButton" toolTip="Add New Row" />
                      </mx:VBox>   
                      </mx:GridItem>

                      </mx:GridRow>

                   </mx:Repeater>
      </mx:Grid>

       

      All of this can be navigated by tabbing through the text fields the hitting the [enter] key to add a new row. (My users prefer to not use a mouse as they are basically doing data entry). Everything works fine except I cannot seem to setFocus on the "txtFirst" text input. I've tried variations of:

       

                  private function resetFocus():void{
                     
                      txtFirst.setFocus();

       

                  }

       

      No luck. Any help would be greatly appreciated.

       

      Thanks