javascript - Can not set Kendo DropDownList selected value - Stack Overflow

I cant set kendo dropdownlist selected item the way i want.so far this is what i tried , but it does n

I cant set kendo dropdownlist selected item the way i want. so far this is what i tried , but it does not seems to work

<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>

i did try to set it like this but i am getting an error

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

and it give me error

Uncaught TypeError: Cannot read property 'value' of undefined

How can i set this value?

I cant set kendo dropdownlist selected item the way i want. so far this is what i tried , but it does not seems to work

<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>

i did try to set it like this but i am getting an error

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

and it give me error

Uncaught TypeError: Cannot read property 'value' of undefined

How can i set this value?

Share Improve this question edited Mar 16, 2018 at 13:02 Ömür Bilgili asked Mar 16, 2018 at 12:59 Ömür BilgiliÖmür Bilgili 1822 silver badges15 bronze badges 2
  • Have you taken a look at the documentation for Kendo DropDownList? – ShawnOrr Commented Mar 16, 2018 at 13:06
  • Yes, but i can not find any sample for selected item when dynamic data binding. – Ömür Bilgili Commented Mar 16, 2018 at 13:08
Add a ment  | 

2 Answers 2

Reset to default 2

if you want the solution without writing the id you can use it

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

It might be just a typo, but I have kendo dojo working.

In first line you don't have id selector, which are you using in jQuery.

For MVVM binding and dataSource you can use data-bind attribute.

<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>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745478817a4629469.html

相关推荐

  • javascript - Can not set Kendo DropDownList selected value - Stack Overflow

    I cant set kendo dropdownlist selected item the way i want.so far this is what i tried , but it does n

    3小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信