Declined
Last Updated: 13 May 2021 10:37 by ADMIN
Karthik
Created on: 10 May 2021 14:27
Category: GridView
Type: Bug Report
1
Delete Keyboard Button Doesn't work after Exiting Edit Mode with ESC

Hello, 

I believe that I have found a bug with the delete keyboard functionality using the delete key. Below are the steps to reproduce:

  1. Click on any row of the grid view.
  2. Observe the row is selected.
  3. Click any cell in the selected row to enter into edit mode.
  4. Exit edit mode using escape.
  5. Observe the row is still selected.
  6. Now click the delete button.
  7. Observe the delete operation doesn't work.

 

Note that if the user selects a new row and then selects the previous row the delete works. 

Demo to illustrate is in SDK sample browser.

Grid View Examples - Custom Keyboard Command Provider

Please let me know if you need any additional information.

Thank you.

1 comment
ADMIN
Vladimir Stoyanov
Posted on: 13 May 2021 10:37

Hello Karthik,

Thank you for the shared information. 

The described behavior is actually the expected one. Please, allow me to elaborate:

The delete command is designed to work when the row is not in edit mode. When the Escape key is pressed while a cell is edited, the cell leaves edit mode, however the row is still in edit mode. For example, if you have edited several cells in a given row, the first Escape click will revert the value in the current cell and the second Escape click will revert the values for all of the edited cells in the current row. 

With this in mind, you have two options in order to delete a row after a single Escape key press:

- The first one is to cancel/commit the row edit when the Delete key is pressed:

public override IEnumerable<ICommand> ProvideCommandsForKey(Key key)
        {
            List<ICommand> commandsToExecute = base.ProvideCommandsForKey(key).ToList();

            if(key == Key.Delete)
            {
                commandsToExecute.Clear();

                // You can commit or cancel the row edit in order to delete
                //commandsToExecute.Add(RadGridViewCommands.CommitEdit);
                commandsToExecute.Add(RadGridViewCommands.CancelRowEdit);

                commandsToExecute.Add(RadGridViewCommands.Delete);
            }

            return commandsToExecute;
        }

- You can exit the row edit as well as the cell edit when the Escape key is pressed:

public override IEnumerable<ICommand> ProvideCommandsForKey(Key key)
        {
            List<ICommand> commandsToExecute = base.ProvideCommandsForKey(key).ToList();

            if(key == Key.Escape)
            {
                commandsToExecute.Clear();
                commandsToExecute.Add(RadGridViewCommands.CancelCellEdit);
                commandsToExecute.Add(RadGridViewCommands.CancelRowEdit);
            }            

            return commandsToExecute;
        }

Both of these suggestions use the approach of defining a custom Keyboard Command Provider. Do give them a try and let me know how it goes. 

Regards,
Vladimir Stoyanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.