2 Replies Latest reply on Feb 24, 2010 8:57 PM by bharghava.raparla

    Problem with repeater nesting

    bharghava.raparla

      Hi,

       

      I have requirement like

        i have outer repeater(groupRepeater) for GroupList. and Inner repeater(friendRepeater) for FriendList. I am iterating through Group Repeater to create canvas in an accordian and when it comes to inner repeater i want to perform comparision if the group_id in friendRepeater is equal to id in groupRepeater then i want to show that user in that particular group.

       

      Please suggest me how can i achieve this.

       

      <mx:Repeater id="groupRepeater" dataProvider="{groupList}">
                  <mx:Canvas label="{groupRepeater.currentItem.name}">
                      <mx:VBox>
                      <mx:Repeater id="friendRepeater" dataProvider="{friendsList}" >
                          <mx:HBox borderThickness="0" visible="{friendRepeater.currentItem.group_id == groupRepeater.currentItem.id ? true: false }">
                              <mx:Label text="{friendRepeater.currentItem.username}"  width="185" visible="{friendRepeater.currentItem.group_id == groupRepeater.currentItem.id ? true: false }"/>
                              <mx:Button label="Move" click="moveFriend(friendRepeater.currentItem.id,groupCombo.selectedItem)" width="65" visible="{friendRepeater.currentItem.group_id == groupRepeater.currentItem.id ? true: false }"/>
                              <mx:Button label="Delete" click="removeFriend(friendRepeater.currentItem.id)" width="65" visible="{friendRepeater.currentItem.group_id == groupRepeater.currentItem.id ? true: false }"/>
                              <mx:ComboBox id="groupCombo" dataProvider="{groupList}" labelField="name" width="155" visible="{friendRepeater.currentItem.group_id == groupRepeater.currentItem.id ? true: false }"/>   
                          </mx:HBox>
                      </mx:Repeater>
                  </mx:VBox>   
                  </mx:Canvas>
              </mx:Repeater>

       

       

      Thanks and Regards,

      Bharghava Ramudu.

        • 1. Re: Problem with repeater nesting
          Gregory Lafrance Level 6

          This code works.

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
            <mx:Script>
              <![CDATA[
                import mx.collections.ArrayCollection;
                [Bindable] private var groupList:ArrayCollection = new ArrayCollection([
                  {id: 1, name: "group1"},
                  {id: 2, name: "group2"},
                  {id: 3, name: "group3"}
                ]);
                [Bindable] private var friendsList:ArrayCollection = new ArrayCollection([
                  {group_id: 1, id: 1, username: "Bob"},
                  {group_id: 1, id: 2, username: "Tim"},
                  {group_id: 1, id: 3, username: "Sam"},
                  {group_id: 2, id: 1, username: "Ed"},
                  {group_id: 2, id: 2, username: "Mary"},
                  {group_id: 2, id: 3, username: "Susan"},
                  {group_id: 3, id: 1, username: "Carl"},
                  {group_id: 3, id: 2, username: "Frank"},
                  {group_id: 3, id: 3, username: "Chris"}
                ]);
              ]]>
            </mx:Script> 
            <mx:Repeater id="groupRepeater" dataProvider="{groupList}">
              <mx:Canvas label="{groupRepeater.currentItem.name}">
              <mx:VBox>
                <mx:Repeater id="friendRepeater" dataProvider="{friendsList}" >
                  <mx:HBox borderThickness="0" 
                    visible="{friendRepeater.currentItem.group_id == groupRepeater.currentItem.id ? true: false }">
                    <mx:Label text="{friendRepeater.currentItem.username}" width="185" 
                      visible="{friendRepeater.currentItem.group_id == groupRepeater.currentItem.id ? true: false }"/>
                  </mx:HBox>
                </mx:Repeater>
              </mx:VBox>    
              </mx:Canvas>
            </mx:Repeater>
          </mx:Application>
          
          


          If this post answers your question or helps, please mark it as such.


          Greg Lafrance - Flex 2 and 3 ACE certified

          www.ChikaraDev.com

          Flex / AIR Development, Training, and Support Services

          • 2. Re: Problem with repeater nesting
            bharghava.raparla Level 1

            Hi Greg Lafrance,

                      I tried like this but those items are occupying the space. It is showing empty at that point. I dont want that to create those items it self instead of making them visible=false. If you tell me this will be much helpful.

             

            Thanks and Regards,

            Bharghava Ramudu.