This is a migrated thread and some comments may be shown as answers.

Batch Edit and Keyboard Navigation

6 Answers 22 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Albert Shenker
Top achievements
Rank 1
Veteran
Albert Shenker asked on 29 Dec 2016, 08:51 PM

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

Sort by
0
Eyup
Telerik team
answered on 03 Jan 2017, 02:24 PM
Hello Albert,

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
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Albert Shenker
Top achievements
Rank 1
Veteran
answered on 03 Jan 2017, 02:45 PM

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?

0
Eyup
Telerik team
answered on 06 Jan 2017, 12:55 PM
Hello Albert,

Here is a possible solution:
<ClientSettings>
    <ClientEvents OnBatchEditCellValueChanging="GridBatchEditCellValueChangingHandler_CSDC" OnKeyPress="keyPress" />
</ClientSettings>
JavaScript:
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
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Albert Shenker
Top achievements
Rank 1
Veteran
answered on 06 Jan 2017, 03:59 PM

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.

0
Angel Petrov
Telerik team
answered on 11 Jan 2017, 01:49 PM
Hello,

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
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Albert Shenker
Top achievements
Rank 1
Veteran
answered on 11 Jan 2017, 02:16 PM
I have posted the requests in the feedback portal
Tags
Grid
Asked by
Albert Shenker
Top achievements
Rank 1
Veteran
Answers by
Eyup
Telerik team
Albert Shenker
Top achievements
Rank 1
Veteran
Angel Petrov
Telerik team
Share this question
or