如何更改kendo绑定html输入的值 [英] How to change the value of a kendo bound html input
问题描述
我有一个带有自定义弹出框的kendoui网格进行编辑。
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.
但现在我想在javascript中更改文本框的值。所以我现在有这个:
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?
推荐答案
您需要模拟更改事件。试试这段代码:
You need simulate change event. Try this code:
$('#test').val("testvalue").change();
这篇关于如何更改kendo绑定html输入的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!