When I have a Navigable grid and I press Esc on the keyboard while editing/inserting a row, I want to do something (e.g., clean up the newly inserted row altogether from the data). Usually, I can use the OnCancel event for this, but it does not fire when pressing the Esc key on the keyboard.
*** Thread created on customer behalf by admin ***
>OnStateChangedHandler
Yep. That did the trick.
Hi Roland,
Once the Add button is pressed you basically have an item in edit mode, which is an EditItem in the grid state. So, you can track the operations of the user and determine whether you want to do something after they have initiated insertion or editing, and that item becomes null, something like this snippet below.
Note that the edit item will become null when Save/Update is pressed too, which is not a cancel operation, so you may want to keep a more careful track of what the user did in order to write up the exact logic you want.
async void OnStateChangedHandler(GridStateEventArgs<SampleData> args)
{
if(args.PropertyName == "EditItem" && args.GridState.EditItem == null)
{
Console.WriteLine("done editing");
}
}
Regards,
Marin Bratanov
Progress Telerik