3 Replies Latest reply on Jun 10, 2009 5:14 AM by C-Rock

    Hitting ENTER in a DataGrid editable cell

    tatiana1 Level 1

      Here's a question for you. I have a dataGrid that I want to be able to edit only when the user clicks on a particular button. When this happens, I make the dataGrid editable and I make that particular column editable. After the user modifies the cell's content and hits ENTER, I want the edit cell to close and the dataGrid to once again become non editable. Here's the code in my Key.onKeyUp listener:

       

      if(Key.getCode() == Key.ESCAPE || Key.getCode() == Key.ENTER)
      {
           my_dg.getColumnAt(2).editable = false;
           my_dg.editable = false;
      }

       

      If the user hits ESC, the edit box closes correctly. If he hits the ENTER key, the edit box remains visible until he hits ENTER once more. Only then does it disappear. How can I make it close corretly the first time?