2 Replies Latest reply on Jan 4, 2007 1:37 PM by mamadlin

    ComboBox in a DataGrid

      Hi All,

      I have a custom combo box (derived from comboBox with addition of an extra mehtod for searching) and I am using it as the itemRender of a DataGridColumn. Combo box has a data provider of (or source of) an ArrayCollection.
      When I click on a button or change the combo box I'd like to find out what is the selected item? How do I point to the selected combo box.
      Here is part of the code if required, greately appreciate your help or any hints/tips.

      <mx:DataGrid id="timeCardGrid" editable="true" x="0" y="0" width="100%" height="100%" doubleClick="timeCardDoubleClick()" doubleClickEnabled="true" dataProvider="{getTimeCardsList(timeCardsXLC.source)}" >
      <mx:DataGridColumn headerText="myCol" id="TestColumn" dataField="datafield1" editable="false" >
      <comp:customComboBox change="outerDocument.updateItem(data.id)" dataProvider="{outerDocument.ItemsList.source}" />

      [this is probably a simple question but couldn't find it in the examples or by playing around with properties/methods]
        • 1. Re: ComboBox in a DataGrid
          ntsiii Level 3
          You don't. When working with data-driven controls, you never directly access the items in the display, but rather you work through the dataProvider. This is because Flex/Flash re-uses the visual components when the list is scrolled. So only the elements, say the combo boxes, that are currently visible actually exist.

          This means any itemRenderer that is interactive must update the dataProvider when the user updates the control state.

          Here is an example using a checkBox:

          • 2. ComboBox in a DataGrid
            mamadlin Level 1
            Hi Tracy,

            Thanks a lot for your reply, the hint was very helpful.
            The resultant working code certainly looks simple, but it took couple of hours to get there. (it thought it was odd that the object passed as a parameter to set of combobox was the whole selectedItem of grid!)
            In anycase, if anyone else has the same problem, all I had to do was to implement accessors method for data (set and get) and write a function that handles change event.