by dloverin

 Comments (13)

Created

May 6, 2011

The Spark DataGrid starts cell editing when a selected cell is clicked. But what if you want your DataGrid to start editing a cell regardless of whether the cell is selected or not? It is pretty easy to do this by adding a few listeners to the DataGrid. In a future release of the Spark DataGrid we will most likely add a property that will allow you to choose which method is used to start an editor session.

Download the project to see how it’s done.

The project also shows show to use the DateField and the ColorPicker as cell editors.

Run the application (required Flash Player 10.2 or greater)

COMMENTS

  • By smithfox - 12:23 PM on July 24, 2011   Reply

    Thank your great example!!

    trackback: http://www.smithfox.com/?e=167

  • By Gabriele Genta - 7:49 AM on August 6, 2011   Reply

    Hello,
    I have a problem with your code: I copied and pasted the part related to single click editing in a grid with a set of plain GridColumns (no custom renderer or editor); it works great for the first click, but then, if you click outside the editor (say for example on the cell to the right of it), the editor doesn’t always show up and the selection gets moved randomly (as far as I can tell) on the row.
    Any idea on how to fix this?
    Thank you,

    Gabriele

    • By dloverin - 6:19 PM on August 8, 2011   Reply

      Could you post a code snippet so I can try it out.

  • By Duong - 1:41 PM on September 16, 2011   Reply

    It would be great if you show us how to add copy/paste support using Ctrl+c/v, since by default we don’t have them in “keyboard and mouse shortcuts with item editors for the Spark DataGrid”.

    Regards

  • By dloverin - 2:20 PM on September 16, 2011   Reply

    Support for copy/paste is built into the text component that is used for the cell editor. You don’t need to add it yourself.

  • By Duong - 3:54 PM on September 20, 2011   Reply

    I thought so, too, but when I use a normal TextInput (or TextArea etc) as a renderer, the component does not listen to keyboard ctrl+c/v anymore. I have to right click to paste the content from the clipboard.

    Regards,

    • By dloverin - 6:05 PM on September 22, 2011   Reply

      Are you sure the TextInput has focus before you paste into the field. Try clicking on the control first before the paste operation.

      Check if your custom control is overriding the setFocus() method. This could be the problem. See DefaultGridItemEditor.as for an example.

      • By Duong - 10:38 AM on October 5, 2011   Reply

        Thank you for your answer. I’ve checked again both of your suggestions to make sure but it’s not working.

        The list of supported shortcuts is specified here : http://help.adobe.com/en_US/flex/using/WS0ab2a460655f2dc3-427f401412c60d04dca-7ff3.html , and I’ve had a look at the code, too.

        Regards,

        • By dloverin - 11:12 AM on October 5, 2011   Reply

          Given that paste works in my demo, there must be something different about your grid editor. Could you post a small example that demonstrates the problem?

          • By Duong - 4:26 PM on November 7, 2011  

            Hi,
            Sorry I couldn’t answer sooner. I’ve taken your example SingleClickCellEditor and replace the line 100 with :

            And then copy/paste just stops working. I think that there’s a logical bug in the process of generating/using the itemEditor inside the DataGrid, where the EditManager does not dispatch COPY/PASTE event anymore.

            Maybe it’s an Air related problem because I’ve tested the NumericStepper example found on http://help.adobe.com/en_US/flex/using/WS0ab2a460655f2dc3-427f401412c60d04dca-7ff3.html, the copy/paste works on my browser but not with my air project.

            To work around this, I’m not sure where I should listen to and dispatch those events in my ItemEditor implementation :-)

            Regards,

  • By marcelo - 12:51 PM on November 27, 2011   Reply

    Thank you very much!!!!

ADD A COMMENT