5 Replies Latest reply on Dec 13, 2006 12:20 PM by ntsiii

    DataGridColumn labelFunction Problem

    Macys_Mike Level 1
      I am trying to get the DataGrid to behave normally, as most DataGrids do. Here's the setup....
      For example:
      ColumnA: Qty. (default value: 0)
      ColumnB: Price (default value: 9.99)
      ColumnC: (ColumnA * ColumnB)

      In this case I'm using a labelFunction to calculate ColumnC. When I run the program and select ColumnA (Qty.) and I change the value from 0 to 1 and I hit the "ENTER" key, the calculation is executed and ColumnC is updated as expected. But, if I hit the "TAB" key instead, it moves the focus to the next editable cell on that row, but it does not execute the calculation (labelFunction). This to me seems like it should be a given, since most DataGrids in most development platforms support this type of behavior (execute on lostfocus/leavecell, etc). But, it looks like it's not built into Flex 2.0's DataGrid.

      My other thought, was to try to capture the "Leave Cell" event....I was unable to find a "Leave Cell" event.
      Any thoughts, ideas or suggestions would be greatly appreciated!
      - Mike
        • 1. Re: DataGridColumn labelFunction Problem
          ntsiii Level 3
          I would expect the behavior you do. Maybe a bug? I think you are on the right track for a work-around. Look into the edit events, something like endEdit? I don't recall exactly.

          Tracy
          • 2. Re: DataGridColumn labelFunction Problem
            Macys_Mike Level 1
            Well, I figured out a work around to this problem.
            I created a blank label called lblTemp. Then I entered the following code in a function that I created to handle the itemEditEnd event:

            this.lblTemp.setFocus();
            this.myGrid.setFocus();

            So far this is working for me. Seems a little odd to have to go this route. If anyone know of a more "proper" way of going about this, I'd love to see it.
            Thanks,
            - Mike
            • 3. Re: DataGridColumn labelFunction Problem
              Macys_Mike Level 1
              Well, my solution works only if you're not using any other controls (as I just found out). Basically, this solution prevents the user from ever moving the focus out to any other control.

              So far, my experience with the implementation of the Datagrid in Flex has been filled with frustration. There are a bunch of "common" scenarios that are proving very difficult to implement.
              For example:
              1) It would be nice to be able to have a calculated column that works. (I set up a labelfunction, but this doesn't update until I leave the row, rather than leave a cell, also it doesn't trigger when using the tab key...see #3).
              2) It would be nice to be able to add a combobox to a datagrid column (I know Flex can do this, but not easily, or intuitively).
              3) It would be nice to be able to control the tabbing behavior in the datagrid, it's doesn't work as one would expect it to. (I set focus to cell in code, then when I hit the tab key, it moves the tab out of the datagrid. When I click back into the datagrid and hit the tab key again...it works as I would expect. But, when I update data in a column and tab off it doesn't trigger the itemEditEnd event...and unfortunately there is no cell edit end event).

              I could go on, but those are my Top 3 problems right now. If anyone has suggestions, ideas or solutions I would love to hear them.
              Thanks,
              - Mike
              • 4. Re: DataGridColumn labelFunction Problem
                ntsiii Level 3
                See if there is anything in this example that will help with #1:
                http://www.cflex.net/showfiledetails.cfm?ChannelID=1&Object=File&objectID=568

                It may not be as easy as you wish, but did you get the comboBox item renderer working right?

                Tracy
                • 5. Re: DataGridColumn labelFunction Problem
                  ntsiii Level 3
                  Also, report bugs, requests here:
                  http://www.adobe.com/go/wish

                  Tracy