Working example: http://dojo.telerik.com/uduto
<div id=
"example"
>
<div class=
"demo-section k-content"
>
<h4>Find a product</h4>
<input id=
"products"
style=
"width: 100%;"
/>
</div>
<script>
$(document).ready(
function
() {
$(
"#products"
).kendoComboBox({
placeholder:
"Select product"
,
dataTextField:
"value"
,
dataValueField:
"id"
,
filter:
"contains"
,
autoBind:
false
,
minLength: 1,
dataSource: {
serverFiltering:
true
,
transport: {
read:
function
(options) {
// below array server the same as remote dataSource
// transport: {
// read: function(options) {
// $.ajax({
// ...
// success: function(response) {
// options.success(response);
// }
// });
// }
// }
options.success(
[{id: 1, value:
"1"
},
{id: 2, value:
"2"
},
{id: 3, value:
"3"
}]);
}
}
}
});
});
</script>
</div>
How to prevent that kendo combobox's dataSource returns all items if dropdown arrow is clicked? I want to achieve that only if at least one character is entered remote datasource request is made. In all other cases, the request is not made. One of the solutions is to add below code to
transport: { read: function(options) { section.
// if comboBox does not have a value return empty result set
if
( $(
"#products"
).data(
"kendoComboBox"
).text().trim().length < 1 )
{
options.success([]);
return
;
}
Also minLength is ignored when clicking arrow