John Edwards
John Edwards

Reputation: 1546

Kendo Data Value

I have the following kendo code:

<script>
   $("#dropdowntest").kendoDropDownList({
                optionLabel: "Select N#",
                dataTextField: "NNumber",
                dataValueField: "AircraftID", 
                index: 0, 
                dataSource: dataSource
            });

I have looked through the kendo documentation but I cannot find how to bind a data SELECTION value. All of the tutorials use the html5 tag as follows.

<select id="dropdown" data-bind="value: selectedProductValue, source: products" >

selectedProductValue allows them to track the value of the selection, but I do not see how to accomplish this without an html tag. I would like to have no html tags at all and do everything in JS. Thanks.

Upvotes: 0

Views: 55

Answers (1)

Satya Ranjan Sahoo
Satya Ranjan Sahoo

Reputation: 1086

Binding data to kendo dropdownlist with MVVM support, "data-bind" attribute is needed. But your code for dropdownlist doesn't use MVVM databinding. So you can ignore the "data-bind" attribute from the html "select" tag. I hope it wont change anything.

As you said "value: selectedProductValue" allows them to track the value of the selection, this can also be achieved by defining "change" event of the dropdownlist. i.e.

    $("#dropdowntest").kendoDropDownList({
            optionLabel: "Select N#",
            dataTextField: "NNumber",
            dataValueField: "AircraftID", 
            index: 0, 
            dataSource: dataSource,
            change: SelectionChanged
        });

   function onChange(e) {
          var selectedValue = e.sender._selectedValue;// track the selected value here
        };

Please en-light if I am wrong.

Upvotes: 2

Related Questions