Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the value of a kendo bound html input

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

In this popup I have an input which is bound to a value of the grid:

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

This works fine. Click edit in the grid, change the value in the textbox and the value propagates to the grid.

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

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

This indeed changes the value of the textbox, but upon save the new value isn't propagated to the grid. I guess because no change event occurs on the textbox.

How do I make this work?

like image 592
Flores Avatar asked Apr 11 '13 17:04

Flores


People also ask

How do you bind data in kendo grid?

Bind data to Kendo Grid by using AJAX Read action method. Change the datasource on change event of any HTML controls. Normally, a developer can bind the data to Grid by using AJAX Read method. This read method is ActionResult method in MVC which will return JSON DataSourceResult & direclty bind the data to Grid.

What is Kendo UI for jQuery?

Kendo UI for jQuery is a professional grade UI library with 110+ components for building modern and feature-rich applications. To try it out sign up for a free 30-day trial.


1 Answers

I tried the above answer but did not work for me. Although the value had indeed changed, the view did not reflect that fact. This worked for me:

       var myvar = $("#myid").data("kendoNumericTextBox");
       myvar.value("newValue");
       myvar.trigger("change", { value: myvar.value() });
like image 162
user3833583 Avatar answered Oct 03 '22 22:10

user3833583