admin管理员组

文章数量:1431435

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>

本文标签: javascriptCan not set Kendo DropDownList selected valueStack Overflow