Alexey Kulikov
Alexey Kulikov

Reputation: 1147

How to disable default keyboard shortcuts in Kendo UI?

How can I disable default shortcuts like arrow up / arrow down in kendoNumericTextBox? By default this controll increment/decrement value then push up/down arrow. I cant find the way to disable it.

Upvotes: 1

Views: 2194

Answers (2)

Termininja
Termininja

Reputation: 7036

You can disable arrow up and down keyboard shortcuts by unbinding the "keydown" event handler:

<input id="ntbox" />

<script>
    $("#ntbox").kendoNumericTextBox().data("kendoNumericTextBox").element.unbind("keydown");
</script>

Also arrow up and arrow down on the widget can be disabled if they are not rendered, the widget is readonly or disabled.

<input id="ntbox1" />
<input id="ntbox2" />
<input id="ntbox3" disabled="disabled" />

<script>
    // Hidden spin buttons: the up and down spin buttons are not rendered.
    $("#ntbox1").kendoNumericTextBox({ spinners: false });

    // Read-only widget: when the widget is readonly it doesn't allow user input.
    $("#ntbox2").kendoNumericTextBox().data("kendoNumericTextBox").readonly();

    // Disabled widget: the value of a disabled widget is not posted as part of a form.
    $("#ntbox3").kendoNumericTextBox().data("kendoNumericTextBox").enable(false);
</script>

Upvotes: 2

Gene R
Gene R

Reputation: 3744

There is much easier way, just set step:0

$("#numerictextbox").kendoNumericTextBox({
    step:0
});

Upvotes: 4

Related Questions