2 Replies Latest reply on Jul 24, 2008 9:55 AM by Garyl Woolworth

    Repeater conditional creating ui

    vikceo Level 1
      Well i have a Array as a datasource say values {"A","B","C","D"}

      using a repeater i want to create a ui with each value in the array as a label element. this is pretty easy.

      but, I want to do it on the basis of some condition like say if the value in the array is "C' then i dont want to create a label for it..

      any idea how to achieve this?
        • 1. Re: Repeater conditional creating ui
          Level 7

          "vikceo" <webforumsuser@macromedia.com> wrote in message
          news:g69vl8$9nk$1@forums.macromedia.com...
          > Well i have a Array as a datasource say values {"A","B","C","D"}
          >
          > using a repeater i want to create a ui with each value in the array as a
          > label
          > element. this is pretty easy.
          >
          > but, I want to do it on the basis of some condition like say if the value
          > in
          > the array is "C' then i dont want to create a label for it..

          Your question isn't very clear, but it sounds like you want to ignore C
          completely.

          If so, use an ArrayCollection instead and filter out C with a
          filterFunction.

          If that is not what you want to do, then just use something like this in the
          label's visibility property within your itemRenderer file:

          <mx: label visibility="{myProperty!='C'}" text = "{myProperty}" />

          HTH;

          Amy


          • 2. Re: Repeater conditional creating ui
            Garyl Woolworth Level 1
            If you set the label visibility based on 'C' it will still create a component so say within a VBox you'll have a gap between the items. If this is not desirable a better way be to go with either the filter function or create a seperate dataProvider that has the items you don't want created already removed and use that for a repeater. Your other option is to skip the repeater and use straight AS 3 running a loop over your array. You can then check for C in your loop and if it's true don't create a new component in your loop. It all depends on your desired result of which one would be better to use.