5 Replies Latest reply on Jan 31, 2009 3:59 PM by cokeeffe

    Filtering XMLList used for DataGrid

    cokeeffe
      I'm using an HTTPService to load a database table into an XMLList, which is then used as the dataProvider for a dataGrid. I can't find anything online for filtering this datagrid , i can only find stuff for filtering using an ArrayCollection, can someone help me? I'd prefer not to have to send HTTPService requests back and forth for filter the datagrid, I'd rather just filter the XMLList that was loaded at the start of the application
        • 1. Re: Filtering XMLList used for DataGrid
          Level 7

          "cokeeffe" <webforumsuser@macromedia.com> wrote in message
          news:gl2m9d$t7q$1@forums.macromedia.com...
          > I'm using an HTTPService to load a database table into an XMLList, which
          > is
          > then used as the dataProvider for a dataGrid. I can't find anything online
          > for
          > filtering this datagrid , i can only find stuff for filtering using an
          > ArrayCollection, can someone help me? I'd prefer not to have to send
          > HTTPService requests back and forth for filter the datagrid, I'd rather
          > just
          > filter the XMLList that was loaded at the start of the application

          Once you have the ArrayCollection, you can set a filterFunction on it and
          call refresh(), without having to call back to the server.

          HTH;

          Amy


          • 2. Re: Filtering XMLList used for DataGrid
            ntsiii Level 3
            But wait. Amy said ArrayCollection, but if you already have an XMLList, you can use XMLListCollection instead.

            Both collections have similar APIs.

            To create an ArrayCollection properly, you would need to define a value object class, then loop over the XMLList, and assign attribute values to the appropriate value object properties. This is actually the ideal, but is a good bit of work.

            An XmlListCollection is much easier to create:
            _xlcMyData = new XMLListCollection(myXMLList)

            You can use both the collection API, and sometimes the e4x API as well.

            Still another possibility is to stay with XML entirely. Filter the XMLLists as needed using the very powerful e4x API.
            • 3. Re: Filtering XMLList used for DataGrid
              cokeeffe Level 1
              OK, I've got it to work using this

              var items:XMLList = event.result.person.(city == txtSearch.text);

              where txtSearch is a text box. However my problem now is, I have to spell the word fully and correctly for it to show the appropriate results. If I don't, while I'm typing the word, the datagrid goes empty, and then once spelt correctly, the results appear.

              So is there a way to show the relevant results while im typing the word.

              EG, If I wanted New York results to appear, If I type in Ne , most words beginning with Ne would appear in the datagrid.

              Kind of like how the % or modulus works in SQL queries to show similar results.

              thanks
              • 4. Re: Filtering XMLList used for DataGrid
                Level 7

                "cokeeffe" <webforumsuser@macromedia.com> wrote in message
                news:gm1vfg$5ja$1@forums.macromedia.com...
                > OK, I've got it to work using this
                >
                > var items:XMLList = event.result.person.(city == txtSearch.text);
                >
                > where txtSearch is a text box. However my problem now is, I have to spell
                > the
                > word fully and correctly for it to show the appropriate results. If I
                > don't,
                > while I'm typing the word, the datagrid goes empty, and then once spelt
                > correctly, the results appear.
                >
                > So is there a way to show the relevant results while im typing the word.
                >
                > EG, If I wanted New York results to appear, If I type in Ne , most words
                > beginning with Ne would appear in the datagrid.
                >
                > Kind of like how the % or modulus works in SQL queries to show similar
                > results.

                Use a filterFunction on the dataProvider.


                • 5. Re: Filtering XMLList used for DataGrid
                  cokeeffe Level 1
                  I'm using XMLList so there is no filterFunction