Cancel Edit and Delete Behavior

3 posts, 1 answers
  1. Steve
    Steve avatar
    124 posts
    Member since:
    Jun 2011

    Posted 21 Jun 2013 Link to this post

    I have read that after inserting a new row in edit mode, it takes two Escape presses to allow the row to be deleted.  Why does it take two presses, what is the underlying functionality that requires this, and is there a way to configure it so the user only has to press once?

    Thanks in advance,
    Steve
  2. Answer
    Maya
    Admin
    Maya avatar
    4062 posts

    Posted 25 Jun 2013 Link to this post

    Hello Steve,

    The first pressing of Escape makes the cell go out of edit mode and the second one reverts the changes made to the underlying property. 
    What you can try is to create your own custom keyboard command provided (as illustrated in this article and this blog post) and change the commands executed for Escape key to CancelRowEdit.
    For example:

    public override IEnumerable<ICommand> ProvideCommandsForKey(Key key)
            {
                List<ICommand> commandsToExecute = base.ProvideCommandsForKey(key).ToList();
                if (key == Key.Escape)
                {
                    commandsToExecute.Clear();
                    commandsToExecute.Add(RadGridViewCommands.CancelRowEdit);
                }
     
                return commandsToExecute;
            }


    Regards,
    Maya
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Steve
    Steve avatar
    124 posts
    Member since:
    Jun 2011

    Posted 25 Jun 2013 Link to this post

    Works like a charm, Maya!
    Thanks, Steve
Back to Top