I notice when I have Batch edit and Keyboard navigation, that hitting the ESC key fires the OnBatchEditCellValueChanging event if the value in the editor has changed. I handle this event to process the changed info, but I would think hitting the ESC key would cancel out of any changes. Otherwise, there really doesn't appear to be any way to prevent a changed status once any of the text has been modified.
IMO the ESC key should cancel any changes and take the cell/row out of edit mode without any changed values. Your thoughts? Is there any way to circumvent this behavior? Obviously, if the value is changed, I want to capture that in all instances... except when a user hits the ESC key.
6 Answers, 1 is accepted
Yes, your reasoning is absolutely right. But isn't the keyboard navigation with Batch editing mode working that way on your side? As you can see here Enter key should change the value, however, ESC should return the value to its original state:
http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/batch-editing/defaultcs.aspx
Regards,
Eyup
Telerik by Progress
As I mentioned, I am handling the OnBatchEditCellValueChanging event to process changes. The reason I do this, is I am taking the "batch" out of batch editing and simply using the batch-editing interface to perform client-side editing. When cells are changed, the info is updated immediately through a webservice without the need to click on a button to submit all changes. When I do this, I need to return the cell to its original unedited state after the update is made (ie get rid of the red triangle indicating a change was made). So I handle the event, update the data through the webservice and use the BatchEditigManager._tryCloseEdits function to set things back to their initial state.
Anyhow, my issue is the OnBatchEditCellValueChanging event gets fired when the user presses ESC if any changes were made in the editor. This doesn't seem to make sense since ESC is designed to cancel any changes. IMO, this event should not fire in response to the ESC key being pressed. You may want to make that change in future versions of the controls. In the meantime, is there any way to capture this keypress inside that event so I can prevent the update from occurring?
Here is a possible solution:
<
ClientSettings
>
<
ClientEvents
OnBatchEditCellValueChanging
=
"GridBatchEditCellValueChangingHandler_CSDC"
OnKeyPress
=
"keyPress"
/>
</
ClientSettings
>
var
keyCode = -1;
function
keyPress(sender, args) {
keyCode = args.get_keyCode();
}
function
GridBatchEditCellValueChangingHandler_CSDC(sender, args) {
if
(keyCode != 27) {
alert(
"Execute custom logic"
);
}
}
Regards,
Eyup
Telerik by Progress
Thanks, that worked. A couple questions...
1) I think the keyCode property is being deprecated (according to https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode)
can I assume your underlying get_keyCode() function will begin using the new property (.key, I think) instead whenever it is introduced.
2) In general I think KeyPress is also being frowned upon and replaced by KeyDown. Will you be implementing such an event for the grid?
3) You may want to build it into the grid so that the ESC key cancels out of some of these events firing (like BatchEditCellValueChanging). Or, provide an example on your site. It would seem more intuitive. the ESC should be like a "Cancel" out of the box.
Regarding your points.
1) We will need to alter our internal logic so that the new key property is reflected. However we should carefully plan this in order to make the transition smoother.
2) We do use keydown but only internally (for keyboard navigation). If you want from us to expose a public handler for the event I suggest logging a feature request in our feedback portal.
3) This seems like a good feature request too. I suggest logging it as well. That way our developers will examine the case and improve the functionality for a future release.
Regards,
Angel Petrov
Telerik by Progress