4 Replies Latest reply on Jan 5, 2009 7:35 PM by John Hall

    "in" relational operator

    DPFrazier
      We're trying to figure out how to use the "in" operator in arraycollection filterfunctions. For example,

      return item.ID in <some string or array or collection>

      Does anyone have experience with the "in" operator and what types of operands it works with?

      Thanks,
      Dean
        • 1. Re: &quot;in&quot; relational operator
          Level 7

          "DPFrazier" <webforumsuser@macromedia.com> wrote in message
          news:gjtsae$jfr$1@forums.macromedia.com...
          > We're trying to figure out how to use the "in" operator in arraycollection
          > filterfunctions. For example,
          >
          > return item.ID in <some string or array or collection>
          >
          > Does anyone have experience with the "in" operator and what types of
          > operands
          > it works with?

          I think maybe you want contains()?


          • 2. Re: &quot;in&quot; relational operator
            DPFrazier Level 1
            quote:

            Originally posted by: Newsgroup User

            "DPFrazier" <webforumsuser@macromedia.com> wrote in message
            news:gjtsae$jfr$1@forums.macromedia.com...
            > We're trying to figure out how to use the "in" operator in arraycollection
            > filterfunctions. For example,
            >
            > return item.ID in <some string or array or collection>
            >
            > Does anyone have experience with the "in" operator and what types of
            > operands
            > it works with?

            I think maybe you want contains()?




            Thanks for your reply, Amy.

            I took a look at contains, and it appears to give a true/false on whether the operand is in the collection. Don't know if it works on 2D collections, or with multi-value operands (either an array, or CSV string), but I don't think it's going to give us what we are looking for.

            I'm trying to replicate the IN filter of SQL, where records are extracted based on whether a particular field matches one of the values in a CSV string. The idea is to bring all the data in from the database (we need it for other purposes anyway), and then filter locally using a filterfunction.

            Any other ideas?

            Thanks,
            Dean
            • 3. Re: &quot;in&quot; relational operator
              Level 7

              "DPFrazier" <webforumsuser@macromedia.com> wrote in message
              news:gjua31$7ej$1@forums.macromedia.com...
              >
              quote:

              Originally posted by: Newsgroup User
              >
              > "DPFrazier" <webforumsuser@macromedia.com> wrote in message
              > news:gjtsae$jfr$1@forums.macromedia.com...
              > > We're trying to figure out how to use the "in" operator in
              > > arraycollection
              > > filterfunctions. For example,
              > >
              > > return item.ID in <some string or array or collection>
              > >
              > > Does anyone have experience with the "in" operator and what types of
              > > operands
              > > it works with?
              >
              > I think maybe you want contains()?
              >
              >
              >

              > Thanks for your reply, Amy.
              >
              > I took a look at contains, and it appears to give a true/false on whether
              > the
              > operand is in the collection. Don't know if it works on 2D collections,
              > or
              > with multi-value operands (either an array, or CSV string), but I don't
              > think
              > it's going to give us what we are looking for.
              >
              > I'm trying to replicate the IN filter of SQL, where records are extracted
              > based on whether a particular field matches one of the values in a CSV
              > string.
              > The idea is to bring all the data in from the database (we need it for
              > other
              > purposes anyway), and then filter locally using a filterfunction.
              >
              > Any other ideas?

              That's how I'd do it. I usually maintain one version that's unfiltered for
              "everything" work and another that's filtered for more targeted operations.
              I don't think you get to supply additional arguments to a filter
              function--you'll just need to have a variable or set of variables that it
              knows to look at. One possible approach is to create a custom class just
              for filterFunctions and then give it one or more properties that can be set.
              Then use something like

              myInstance:myFilterClass=new myFilterClass();
              myInstance.properties = {prop1:'value of prop 1', prop2:4};
              myArrayCollection.filterFunction=myInstance.filterFunction;

              You may also want to look at IViewCursor and see if that is helpful.

              HTH;

              Amy


              • 4. Re: &quot;in&quot; relational operator
                John Hall Level 4
                Not that this link is relevant to your specific situation, but I've found this link useful for multiple filters

                http://blog.rotundu.eu/flex/arraycollection-with-multiple-filter-functions/

                might tuck it away in your bookmarks