6 Replies Latest reply on Jun 15, 2010 4:42 PM by JonoB

    Combobox as itemEditor


      I have a combobox as an itemEditor in a datagrid. I have an event listener on the datagrid (DataGridEvent.ITEM_EDIT_END) that calculates the values in adjacent datagrid cells based on the value that has been selected in the combobox. This all works fine.


      The one area that I am struggling with however, is to force the combobox to immediately commit the selected value to the datagrid. At the moment, if a user selected a value from the combo, its necessary to lose focus (i.e. click into another cell on the datagrid, or elsewhere in the app) for the value to be committed (and its at this point that the ITEM_EDIT_END event is fired).


      Ideally, once the user has selected an item in the combo itemeditor, I would like that that the combo retains focus (i.e. remains slightly raised above the datagrid cell), but that the value is immediately committed and an event is fired off.


      Is this possible?

        • 1. Re: Combobox as itemEditor
          Flex harUI Adobe Employee

          Update the data item on the ComboBox's CHANGE event.

          • 2. Re: Combobox as itemEditor
            JonoB Level 1

            Thanks for the reply.


            The itemEditor is a mxml custom component (ProductItemRenderer), so I am embedding it into the datagrid column as follows:




            I can run a CHANGE event on the mxml component, but how do I get that to filter through to the datagrid so that it triggers a DataGridEvent.ITEM_EDIT_END event?

            • 3. Re: Combobox as itemEditor
              Flex harUI Adobe Employee

              Well, you could fake the event, but in my prototypes, I don't bother.  The

              CHANGE event will be reflected in the dataProvider and thus in all the

              renderers and I don't want to shut down the edit session right away in case

              the user goes back and changes the same combobox again.  Then when they tab

              or click on another cell, ITEM_EDIT_END is dispatched but because the

              updated data is already stored there is no change event from the collection.

              • 4. Re: Combobox as itemEditor
                JonoB Level 1

                OK, excuse me being a noob, but how do I get the CHANGE event in the combo to update the dataProvider?


                Sorry, but I'm pretty new to this...

                • 5. Re: Combobox as itemEditor
                  Flex harUI Adobe Employee

                  Depends on the data items.  If they are bindable, just update the

                  appropriate field in the data item.  Otherwise, you have to get to the

                  dataProvider to call itemUpdated.

                  • 6. Re: Combobox as itemEditor
                    JonoB Level 1

                    After lots of trying different things, by far the easiest was to create a custom event on the itemeditor component, which gets dispatched on the combobox close event. The main view that holds the datagrid then has an eventlistener that picks up the event and updates the datagrid dataprovider without the combo losing focus.