2 Replies Latest reply on Oct 25, 2006 3:09 PM by Nataliefay

    ComboBox itemEditor in DataGrid

    rmarp
      Hi folks,

      I must say that I do come across some tricky and annoying things with Flex here and there but overall it really is a kick-*** framework and I love working with it.

      Currently, I've got a situation where I've got an ArrayCollection of Objects which I'm showing in a DataGrid. For a certain field, I want the user to be able to edit it using a drop-down. I've started to work on this, and using an in-line editor I've now got a combo box appearing as the editor for that field using this code:

      <mx:DataGrid dataProvider="{customerArrayCollection}" editable="true">
      <mx:columns>
      <mx:DataGridColumn dataField="customerName" editable="false"/>
      <mx:DataGridColumn dataField="totalSales" editable="false"/>
      <mx:DataGridColumn dataField="classification" editable="true">
      <mx:itemEditor>
      <mx:Component>
      <mx:ComboBox />
      </mx:Component>
      </mx:itemEditor>
      </mx:DataGridColumn>
      </mx:columns>
      </mx:DataGrid>

      I now have the following questions:

      1. How can I get the combobox to open automatically when it's shown? I figure the user has already clicked on the field to edit it, they shouldn't have to click again to expand the combobox. I've tried using the show event to call the open method but the show event doesn't seem to fire when the combobox editor is displayed. Any ideas?

      2. The values that the user can pick from this combobox are not static. Which values should be shown are based on another field in that row. In my example above, the user should be able to set the classification field to A, B, or C if the totalSales field is greater than 0, but if it's 0, then they should only be able to pick from B or C. I'm not sure where to place this logic or how I can get ahold of the other fields values. Any suggestions for me?



      Ryan
        • 1. Re: ComboBox itemEditor in DataGrid
          rmarp Level 1
          Ok I've spent a good chunk of the day on this and have found what I think is the answer to both of these.

          First, on opening the combobox when shown, I ended up using the focusIn event of the combobox to call the open method. It ends up being called whenever the editor appears.

          Secondly, I figured out that the data property that's set into the combobox isn't the field value but the whole row value so you can easily look at other fields and set the dataProvider appropriately.

          Now the only thing I'm stuck on now, is how to get out of edit mode programatically. DataGrid has a private method called endEdit but of course, because it's private I can't call it.

          Anybody tried to do this?

          Ryan
          • 2. Re: ComboBox itemEditor in DataGrid
            Nataliefay
            Hi,

            I'm sorry to bug you with a non-technical discussion, but I am a recruiter in San Diego. My client is in need of 3 Senior Flex Developers for their project. I have had an extremely rough time finding someone for this position. Would you be interested in this position, or do you know of anyone that might be? We do pay referral fees. This position may be open to telecommuting.

            Job Description:
            They are in the midst of a major re-architecting of their Corporate Management system utilizing many cutting edge technologies. As it relates to the position they are using Flex as their UI.

            This is either a contract, or a full-time position.

            Pay: Market Rate

            Thanks for your help!

            Natalie Fay
            Outsource Technical
            www.ostechnical.com
            nfay@ostechnical.com
            858.874.5637