Search code examples
kendo-uikendo-ui-angular2kendo-dropdown

In Angular JS Kendo Drop down not setting the model value


HI I have following Kendo Dropdown, even though I have a value in ng-model, the dropdown is not selecting the default values.

<select name="myDropDown"
                                id="myDropDown"
                                class="width-90"
                                kendo-drop-down-list k-data-text-field="'key'"
                                k-data-value-field="'value'"
                                k-data-source="myDataSource"
                                ng-model="model.selectedProperty"></select>

model.selectedProperty does have the value . However the UI does't select the options.

DataSource Values:

[{"key":"Critical","value":0},{"key":"High","value":1},{"key":"Medium","value":2},{"key":"Low","value":3}]

model.selectedProperty = 1

The above one should have selected the second option, but the dropdown selects none


Solution

  • Well I have to make the selected value same object as in the list:

    $scope.model.selectedProperty = {"key":"Critical","value":0}

    And I updated the select tag to,

    <select name="myDropDown"
                                    id="myDropDown"
                                    class="width-90"
                                    ng-model="model.selectedProperty"
                                    ng-options="option.key for option in myDataSource track by option.value">
                            </select>