Kendo UI: Get TextBox Value on Button Click

13,009

Solution 1

Quickly you can retrieve the value this way using JQuery:

$('#yourTextBoxID').data('kendoMaskedTextBox').value();

Solution 2

Please take a look at these documentation pages:

http://demos.kendoui.com/web/mvvm/index.html
http://docs.kendoui.com/getting-started/framework/mvvm/observableobject
http://docs.kendoui.com/tutorials/mvvm-in-kendo-ui

These pages contain answers to most of the questions you'll have concerning Kendo UI MVVM. It would be silly and presumptuous of me to think that I could explain it better than the qualified and hard working individuals at Telerik that have so painstakingly compiled these documentation pages.

The gist of it is that you need to create an instance of the kendo.data.ObservableObject that has properties for the values you are working with. This is your view-model. Then in your markup for your text boxes, include values for the data-bind attribute that reference the properties in your observable object. Create a function in your view-model to handle the button's click event. Put a data-bind attribute in your button that binds the click event to your function. Finally, call kendo.bind(<element>, <observable object>), and that will connect the wires from your markup to your view-model object.

In your click event-handler, you can take the values of the view-model, and insert them into the object you need. You should not need to use "normal jQuery" for anything besides referencing the element to call bind on.

Share:
13,009
Hardik
Author by

Hardik

Updated on June 15, 2022

Comments

  • Hardik
    Hardik about 2 years

    I am having a form, which comprises of several textboxes and one button.

    I am using the Kendo UI MVVM format. How shall I get the value of each textbox and store it in an object on click of the button?

    Will I have to use normal jQuery in order to get the values or is there some other way of getting the values from each of them?

    Thanks

    Hardik