1
votes

I want to autobind a model to a kendo dropdown list. The model is read from the server. Sometimes the value of the model is undefined sometimes its a legit object.

When the the value is undefined I am having an issue. For some reason kendo is selecting the first item from the drop down list. I would expect kendo to display the drop down list with nothing selected.

See http://plnkr.co/edit/S6xHNBulTbSwHraZQKko?p=preview

 <select kendo-drop-down-list
                name="eventType"
                k-ng-model="itemSelected"
                k-options="eventTypeDropDown">
 </select>

$scope.itemSelected = undefined;

Does anyone know a way to fix this?

Thanks! Zohar

1

1 Answers

1
votes

Try using optionLabel, as so:

$scope.dropDownOptions= {
  optionLabel:' ',
    dataTextField: "name",
    dataValueField: "id",
    autoBind: true,
    dataSource: {
        ...
        }
    }

If your model is undefined this will show the drop down list with nothing selected. This doesn't seem to work if you leave optionLabel blank, it seems to require you have at least a space in it.