16

I have a kendoNumericTextBox. I have code that sets the value of the input element associated with the kendoNumericTextBox. For example, the code calls:

$('#myId').val('test');

Unfortunately, the kendo numeric text box doesn't automatically reflect the value. How can I tell the kendoNumericTextBox to update its value? I know there's a method on kendoNumericTextBox as follows:

$('#myId').data('kendoNumericTextBox').value('test');

However, I'm populating many fields and not exactly sure which ones will be kendoNumericTextBox fields. So, I prefer to call something like I do with the chosen plugin to refresh the value based on the underlying component. For example, with the chosen plugin, I can call:

$('.chosen').trigger('liszt:updated');

to update all values based on the underlying select component's value.

OnaBai
  • 40,767
  • 6
  • 96
  • 125
James
  • 2,876
  • 18
  • 72
  • 116

3 Answers3

20
var numerictextbox = $("#paymentAmount_" + id).data("kendoNumericTextBox");
    numerictextbox.value("0.00");

This works for me. Store the element in a variable and the set the value using double quotes. Also I was not able to put a word in like 'test' in a numericTextBox...I am assuming you meant that as test data. But this should work for you as well.

DeadlyChambers
  • 5,217
  • 4
  • 44
  • 61
5

i was having trouble with this same thing, I However got it working without the quotes...
all that i can say is that it seems to work for now....

 calCalories: function (e) {

        var totalCals = 0;
        totalCals = totalCals + ($("#Carbs").val() * 4);
        totalCals = totalCals + ($("#Protein").val() * 4);
        totalCals = totalCals + ($("#Fat").val() * 9);

        var numerictextbox = $("#Calories").data("kendoNumericTextBox");
        numerictextbox.value(totalCals);
    },

note: one could obviously use the below line of code to get the value from the event

e.sender.value()
Kcats Wolfrevo
  • 803
  • 1
  • 11
  • 15
0

Just trigger change event for kendo numeric textbox

$('#myId').data('kendoNumericTextBox').trigger('change');
Community
  • 1
  • 1
GuChil
  • 137
  • 1
  • 6