Hello,
I believe that I have found a bug with the delete keyboard functionality using the delete key. Below are the steps to reproduce:
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.
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/.