OnKeyPressHandler
Description
An OnKeyPressHandler
is a type that defines a function which will evaluate if the keyboard event can start the edit mode. The EditTriggers
.onKeyPress
provides the common key press functions as well as a custom function to provide specific keys.
Arguments
Parameters |
Type |
Description |
---|---|---|
context |
The context of the key press. |
|
[output] |
boolean |
true when the keyboard event can start the edit mode, otherwise false. |
Example
In the first example, the keyStartEdit
function triggers the edit mode when the key “p” or Alt + “n” is pressed. This function is set as an OnKeyPressHandler
for the EditTriggers
.onKeyPress
.
function keyStartEdit(context)
{
if (context.keyPressed === "p")
return true;
if (context.keyPressed === "n" && context.isAltKeyPressed)
return true;
return false;
}
const editTriggers = {
onKeyPress: keyStartEdit
};
This editTriggers
object should be set in the DataGridOptions
.editTriggers
property.
In this second example, the EditTriggers.onKeyPress.alphaNumerics
function is set as a OnKeyPressHandler
for the EditTriggers
.onKeyPress
. It will trigger the edit mode when a letter key or a numeric key is pressed.
const editTriggers = {
onKeyPress: Xceed.EditTriggers.onKeyPress.alphaNumerics
};
This editTriggers
object should be set in the DataGridOptions
.editTriggers
property.