繁体   English   中英

无法设置Kendo DropDownList选择的值

[英]Can not set Kendo DropDownList selected value

我不能按照我想要的方式设置kendo dropdownlist选项。 到目前为止这是我尝试过的,但似乎没有用

<select name="YolTipleri" required
                data-value-primitive="true"
                data-role="dropdownlist"
                data-text-field="Adi"
                data-auto-bind="true"
                data-value-field="GID"
                data-source="Hede.Components.DataSources.YolTipi"></select>

我确实尝试设置它,但我收到一个错误

$("#YolTipleri").data("kendoDropDownList").value(2);

它给了我错误

Uncaught TypeError: Cannot read property 'value' of undefined

我该如何设置此值?

这可能只是一个错字,但我有剑道道场工作。

在第一行中,您没有id选择器,您在jQuery使用它。

对于MVVM绑定和dataSource,您可以使用data-bind属性。

<select id="YolTipleri" name="YolTipleri" required
    data-value-primitive="true"
    data-role="dropdownlist"
    data-text-field="Adi"
    data-auto-bind="true"
    data-value-field="GID"
    data-bind="source: source">
</select>

如果您想要解决方案而无需编写ID,则可以使用它

$('[name="YolTipleri"]').data("kendoDropDownList").value(2);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM