How to change the value of kendo-related html input

I have a kendoui grid with a custom popup for editing.

In this popup, I have an input that is bound to a grid value:

<input type="text" class="k-input k-textbox" id="test" data-bind="value:SearchFilter"> 

It works great. Click "Edit" in the grid, change the value in the text box, and the value will be transferred to the grid.

But now I want to change the value of the text field in javascript. So now I have this:

 $('#test').val("testvalue"); 

This does change the value of the text field, but after saving, the new value does not apply to the grid. I think because there are no changes in the text box.

How do I do this job?

+6
source share
2 answers

You need to simulate a change event. Try this code:

 $('#test').val("testvalue").change(); 
+25
source

I tried to answer above, but did not work for me. Although value has indeed changed, the point of view did not reflect this fact. This worked for me:

  var myvar = $("#myid").data("kendoNumericTextBox"); myvar.value("newValue"); myvar.trigger("change", { value: myvar.value() }); 
+3
source

All Articles