Ömür Bilgili
Ömür Bilgili

Reputation: 182

Can not set Kendo DropDownList selected 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?

Upvotes: 4

Views: 6512

Answers (2)

volkansendag
volkansendag

Reputation: 51

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

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

Upvotes: 2

Mantas Čekanauskas
Mantas Čekanauskas

Reputation: 2228

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>

Upvotes: 1

Related Questions