DataGrid ItemEditor with Two Input Fields

Several folks have been asking about how to have a DataGrid ItemEditor with two input fields (say you want to separately edit first name and last name or something like that).
It’s a bit tricky because of some missing pieces in the underlying Flash focus APIs and because of how Focus events work. Here is my take on how to do it. Usual caveats apply (i.e, code is not supported and may have bugs etc).
Download Source
Run Example

6 Responses to DataGrid ItemEditor with Two Input Fields

  1. Narendar says:

    very nice!!
    good work.

  2. codecraig says:

    Interesting that “createChildren” gets called everytime you click on the cell.
    I modified yours a little bit to use two comboboxes and I was wondering why in “commitProperties” my comboboxes “dataProviders” were always empty even though I had set them once before 🙂
    —————-
    Alex responds:
    Editors get re-created every time. I haven’t proven it yet, but I think you could create a custom IFactory that recycles a single editor instance

  3. NS says:

    How can I specify background color to the footer? I tried using beginFill function of the Shape, but no luck.
    ——————-
    Alex responds:
    Try the graphics object in the footer.

  4. Eric Belair says:

    Can something similar be done with a TileList TextInput ItemRenderer – i can’t seem to get tabbing to work.
    ———————–
    Alex responds:
    TileList doesn’t support editing. You’ld have to add all of that code first.

  5. ilikeflex says:

    In the sample, use keyboard to tab the complete swf. After all the cell editors and button have recieved the focus atleast once then i noticed then focus goes only on buttons and one cell editor (location: last row + last column). Why does it not goes to first cell editor( location: first row + first column). Can you give any pointer how to make focus work??

    • Alex Harui says:

      The DataGrid does not reset the last editedItemPosition when it loses focus. If someone clicks away in the middle of editing and returns, we restore focus to that place. I think you’ll need custom logic to detect that you’ve tabbed out of the last row/column and on focusIn set editedItemPosition back to the beginning.