7 Replies Latest reply on May 2, 2009 2:59 AM by lerooooogk

    Question about Repeater Control


      Hi all,


      I have the next code:


      <mx:Repeater id="list" dataProvider="{categories}">
              <mx:Label id= "cbox" text="{list.currentItem.toString()}"/>
              <mx:TextInput id="ti_prueba"/>
      <mx:Button label="Apply" click="filter()"/>


      Dataprovider is something like this: ['id', 'source','destination'].


      For each label, i put a TextInput control to write a value. This value and label will be needed to filter a datagrid component.


      I'm trying to design a way to iterate repeater control. My purpose is to verify the value of TextInputs and put them into an array. Then, i'd have another array with label values and with both i'd filter a datagrid.


      My problem is when I'm trying to access into the repeater. I looked for it in Internet but nothing helped me.


      For example i tried:


      public function filter():void{
       for (var i:int = 0; i < list.count < i++){
           tiValue[i] = ti_prueba[i]


      But nothing happens.


      An idea please? I read something about currenItem but i dont found the way to apply it for my purpuse.


      Thanks in advance,



        • 1. Re: Question about Repeater Control
          Gregory Lafrance Level 6

          Repeater currentItem is only accessible when the repeater is executing.


          In your case, just access the dataProvider, which you would best use an XMLListCollection, so you can e4x syntax for filtering etc.

          • 2. Re: Question about Repeater Control
            lerooooogk Level 1

            Hi Greg,


            thanks in advanced. Really I already do that you say. The reason I use repetater control is that the values are dynamic so they change several times.


            Before, I used an XMLListCollection and I filter each item by name (for example) but each item has a dynamic number of params (id,destination..) so some items can have X params and other Y params (is possible to add new params in the future).


            I "catch" all params of all events and I remove duplication params.


            This is the reason that I use a repeater control. If I load one xml file the params probably wouldn't be the same than others (probably there would be new ones too). My porpuse is to filter each item by params.


            The filtering works correct (I try it putting "manual" values into array). I'd like that action was automatic (putting values into array) with repeater. "Just that"


            I'm not sure if I explained well this.





            • 3. Re: Question about Repeater Control
              Gregory Lafrance Level 6

              Not sure I'm following you, but I feel Repeater is not appropriate for this.


              Depending on where the data is being used, you might be able to use a labelFunction, or filterFunction, or creationComplete handler to do the processing.

              1 person found this helpful
              • 4. Re: Question about Repeater Control
                ntsiii Level 3

                I have two possible approaches to suggest.


                First, have a change event handler on the TextInput update a property in your dataProvider item. In the change handler you could use getRepeaterItem() to get a reference to the item, and event.target to get a reference to the TextInput.


                Second, if yo give the TextInput an id, like "myTI" repeater will automatically generate an array of references you can use"

                var aCurValues:Array = new Array()

                for (var i:int=0;i<myTI.length;i++)  {

                     aCurValues[i] = myTI[i];




                • 5. Re: Question about Repeater Control
                  lerooooogk Level 1

                  Hi Greg and Tracy,


                  lof of thanks for your answers. Finally, I did something as Tracy said.


                  I have in a mess now too .

                  Three files:

                  1. A mxml file where I have a Datagrid and some button control.

                  2. I created one component and put into that mxml file.

                  3. I have an actionScript file where I put some code to filter datagrid


                  Its contructor (actionScript file):


                  public function MatchFilter(grid:DataGrid)
                                 _grid = grid;          


                  When I'm working in mxml file (file number 1) I have no problem when I want to use one method of that file. For example:


                  //When the mxml is created
                  public function init():void{
                       matchFilter = new MatchFilter(dg_events);
                  //Filter By no-dynamic Params
                  public function matchChanged():void{
                       matchFilter.match(_text.text, _select.selectedItem.dataField);


                  If I debug, the reference for Datagrid is correct.


                  My problem is when I want to used one method of that actionScript file wiht my component file (number 2) which is into mxml file too. I need to pass datagrid (dg_events) but I dont found the way.


                  Actually I do this:


                  public var matchFilter:MatchFilter;
                  private function filterParam():void{
                        var nameParam:Array = new Array();
                        var valueParam:Array = new Array();
                        for (var i:int=0; i < this.cbox.length; i++)
                           nameParam[i] = this.cbox[i].text;
                           valueParam[i] = this.ti_prueba[i].text;
                           matchFilter = new MatchFilter(filterDetails.dg_events);     
                           matchFilter.matchParam(nameParam, valueParam);


                  "filterDetails" is mxml file and dg_events the datagrid that i want to pass to create an instance of matchFilter. If I debug when I do that, dg_events is null so it doesn't work.


                  Thanks in advance (again ),



                  • 6. Re: Question about Repeater Control
                    Gregory Lafrance Level 6

                    Access objects in the main app with Application.application.myObject, and objects in those objects with Application.application.myObject.myVar.

                    1 person found this helpful
                    • 7. Re: Question about Repeater Control
                      lerooooogk Level 1

                      Thanks for your answer.


                      Finally, I could solve my problem with your advices.