3 Replies Latest reply on May 5, 2010 3:01 PM by EWN-CMI

    Reference Variable syntax??

    EWN-CMI Level 1

      I have a large table that I want to filter on any field. I have the dataProvider array and the fieldname in a variable.  Can anyone point me in the right direction on how to set up a dynamic filter, all I can find are static item.arrayLabel in a filterFunction  where item is the dataProvider and arrayLabel is the "column" (item.city or item.state versus item[fieldName] where fieldname can be "data" or "label").  My ultimate goal is to eliminate [object Object] from the list if there are any NULL items in the database for that fieldname.  All help is appreciated.

        • 1. Re: Reference Variable syntax??
          EWN-CMI Level 1

          should read (item.city or item.state versus item[fieldName] where fieldname can be "city" or "state")

          • 2. Re: Reference Variable syntax??
            GordonSmith Level 4

            If you have data items like

             

                dataProvider =

                [

                    { city: "San Francisco", state: "CA" },

                    { city: null, state: "CA" }

                ];

             

            and a fieldName like

             

                fieldName = "city";

             

            then a filter function like

             

                return item[fieldName] != null

             

            will let through only the items where the city field is null.

             

            Gordon Smith

            Adobe Flex SDK Team

            • 3. Re: Reference Variable syntax??
              EWN-CMI Level 1

              Thanks Gordon,  it seems my syntax was correct but my logic failing.  My filterFunction was (item[fieldName]!="" || item[fieldName]!=null) instead of &&  I had no confidence in the syntax. Hate it when I doubt myself

               

              Thanks again. This is going to be a pretty slick SQL generator for reporting once complete. Here we are selecting the WHERE criteria for the fields included in the report.  My previous question (unanswered) instead of rendering ComboBox for each row, only fields with lookup tables would have had a ComboBox and these other potentially null fields were going to render TextInputs - but never could get that working with dynamic dataProviders.  This may be a better solution, just need to make the non-lookup ComboBoxes editable.

               

              Thanks again.