5 Replies Latest reply on Oct 15, 2009 3:38 AM by ttruckle

    modify last result data

    ttruckle

      in Gumbo I connect a http service to a combo box - this works fine.

      but before putting the entries in the list of the combo box I want to do some changes

      over the data (sorting, delete some data and others).

      How can I hook up to put my own functions in

      (result handler or what ??)

       

      best regards,

       

      t.t.

        • 1. Re: modify last result data
          David_F57 Level 5

          normally in your resulthandler you would put the result into some type of bindable array such as xml or array collection this array should be your comboboxes dataprovider.  If you want to manipulate this data it is better to iterate through the result  and put the data you want into the bound array.

           

          something like this

           

          instead of

          myArray = myreturn.result

           

          you may do something like this

           

          for (var i:int=0; i < myreturn.result.length;i++)

          {

             //do some stuff i.e;

            if myreturn.result[i].id < 1000 myArray.addItem(myreturn.result[i].id)

          }

           

          if (myArray.length > 0) runMySortRoutine();

           

           

          David.

          1 person found this helpful
          • 2. Re: modify last result data
            ttruckle Level 1

            Hi David,

            thanks for the answer.

            I'm afraid I'm not fully understand the mechanism of the ACT.

            Do you got any informations (links) for further informations about it?

             

            To clarify my problem:

             

            I got a comboBox with:

             

            <mx:ComboBox x="100" y="320" width="170" editable="false" height="18" contentBackgroundColor="#323232" id="idCountryText" change="idCountryText_changeHandler(event)" creationComplete="idCountryText_creationCompleteHandler(event)" dataProvider="{getListOfCountriesResult.lastResult}" labelField="Country" fontSize="10" textAlign="left"/>

             

            I got a creationcomplete handler:


            protected function idCountryText_creationCompleteHandler(event:FlexEvent):void
            {
               getListOfCountriesResult.token = phpService.getListOfCountries();
            }

             

            and I got a Call Responder (under <fx:Declarations>)

             

            <s:CallResponder id="getListOfCountriesResult" />

             

             

            if I start the applcation I got a wonderfull list of countries from mysql in my combobox,

            but where exactly should I hook in to modify the data before they will be pass to the combobox...

             

            thanks in advance,


            ttruckle

            • 3. Re: modify last result data
              ttruckle Level 1

              just an idea:

               

              is it wise to put the code in class CountryList.as

               

              (flash builder 4 automaticly made this class stub for me

              which extends _Super_CountryList and is apperently

              made for custom code..)

               

              as a review of my question:

               

              So far, I understand: the data I need is in

              "getListOfCountriesResult.lastResult"

              but which event is fired if this array changes ???

               

              tt.

              • 4. Re: modify last result data
                David_F57 Level 5

                When you start the application it fires the phpservice to get your data - phpService.getListOfCountries();

                 

                so in the getListofCountries method you should be able to setup a result handler. that is where you could manipulate your data.

                 

                when data changes it is calling the "idCountryText_changeHandler(event)" this would be fireing a phpservice maybe something like phpService.updateCountries(value)

                 

                So the update service may need to be 'adjusted' if you change something in a result handler.

                 

                the combobox has a dataprovider which is bound to the result - dataProvider="{getListOfCountriesResult.lastResult}"

                you don't have to bind to the result you could create your own array from the result then it could be bound to the combobox but that means you need to do a bit of work in the update process to ensure that the table gets data from your new array.

                 

                David.

                • 5. Re: modify last result data
                  ttruckle Level 1

                  thanks for the answer.

                   

                  I found another easy way to "hook-in"

                   

                  I changed:

                   

                  <s:CallResponder id="getListOfCountriesResult"/>    to

                  <s:CallResponder id="getListOfCountriesResult" result="filter_country()" />

                   

                  so I can create a function filter_country() and inside I can do my custom stuff

                  by copy getListOfCountriesResult.lastResult to a new AC (which is BINDABLE)

                  an make this my new data provider for the combo-box...

                   

                   

                  again: thanks for you attention,

                   

                  greetings,

                   

                  t.t.