5 Replies Latest reply on Jul 3, 2008 11:10 AM by ntsiii

    Id for the control in repeater

    rajeeva_nagaraj
      Hi,

      I am generating dynamic textinput using repeater, is it possible to give id for each textinput created in repeater
      (i am able to set text for each textinput but unable to set id for each text input)

      plz find me some solution for my problem

      thanks in advance
        • 1. Re: Id for the control in repeater
          donarbxc
          Sure, just use data binding to create it for you:

          <mx:Repeater id="repeater"...
          <mx:TextInput id="{'MyTextControl' + repeater.currentIndex}" ...


          This will create controls with ids of MyTextControl0, MyTextControl1, etc.

          • 2. Re: Id for the control in repeater
            rajeeva_nagaraj Level 1
            Hi,

            I tried that but its giving error "is not a valid identifier"

            i am sending my code

            <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="GetProjectName.send()">
            <mx:HTTPService id="GetProjectName" url=" http://localhost:1436/Repeater/Default.aspx" useProxy="false" />
            <mx:TabNavigator id="NewTab" width="100%" height="100%" creationPolicy="all" >
            <mx:Repeater id="MyRepeater" dataProvider="{GetProjectName.lastResult.NewDataSet.Table}">
            <!--mx:CheckBox label="ABCD" /-->
            <mx:Canvas label="{MyRepeater.currentItem.ProjectName}" height="477">
            <mx:DataGrid width="90%" height="353">
            <mx:columns>
            <mx:DataGridColumn headerText="A" width="100"/>
            <mx:DataGridColumn headerText="B" width="100"/>
            <mx:DataGridColumn headerText="C" width="100"/>
            <mx:DataGridColumn headerText="D" width="100"/>
            <mx:DataGridColumn headerText="E" width="100"/>
            </mx:columns>
            </mx:DataGrid>
            <mx:TextInput id="{'MyText' + MyRepeater.currentIndex}" x="10" y="413"/>
            </mx:Canvas>
            </mx:Repeater>
            </mx:TabNavigator>
            </mx:Application>

            plz find me some solution to add ids for each control
            • 3. Re: Id for the control in repeater
              Giri s Level 1
              Hi rajeeva_nagaraj,

              I am also facing the same issue with the id attribute with dynamic binding. How did you resolve the issue?

              Thanks
              • 4. Id for the control in repeater
                Giri s Level 1
                I found the solution...

                give any text as id

                <mx:TextInput id="MyText" x="10" y="413"/>

                and can iterate through that id.

                public function showInput():void {
                for (var i:int = 0; i < MyText.length; i++)
                Alert.show(MyText{i}.text);
                }

                it shows all the TextInput input values.

                Thanks
                Giri
                • 5. Re: Id for the control in repeater
                  ntsiii Level 3
                  Giri has the correct solution (though use brackets and not braces).

                  You cannot create ids dynamically in a repeater as in the first suggestion.

                  Tracy