I have an angular directive that wraps a virtual kendo ui dropdown. The issue i'm having is that even though i am setting the dataValueField when i select an dropdown item the k-ng-model bound field is set to the entire item object rather than the property of the object specified by the dataValueField. Not sure what i'm doing wrong.
var selectDataSource = new kendo.data.DataSource({
transport: {
read: function(options) {
var currentPage = getItemPage(options.data.skip, options.data.take);
options.success(currentPage);
}
},
schema: {
data: "currentPage",
total: "total"
},
pageSize: pageSize,
serverPaging: true // enable serverPaging so take and skip are sent as
});
//setup the dropdown options object
scope.dropDownListOptions = {
dataTextField: scope.textField, // 'name'
dataValueField: scope.valueField, // 'id'
dataSource: selectDataSource,
height: height,
virtual: {
itemHeight: 26,
valueMapper: function(options) {
var itemIndex = scope.itemList.findIndex(function(element, index, array){
return options.value === element[scope.textField];
});
options.success(itemIndex);
}
}
}
/*directive html*/
<select id="{{selectId}}"
kendo-drop-down-list
k-options="dropDownListOptions"
k-ng-model="modelValue"></select>
The other question relates to the optionLabel default option. Is there any way to disable this option so that the user can't select it?