Filter DataSource Manually
The Kendo UI ComboBox has a built-in detection mechanism that checks whether the data is filtered or not.
This information is used by the widget to decide when to persist the selected value that does not exist in the source. When the source is manually filtered, the ComboBox loses the details about the state of the Data Source and, as a result, might fail to operate.
The following example demonstrates how to manually filter the Data Source instance of the Kendo UI ComboBox.
<div id="example">
<div class="demo-section k-header">
<h4>ComboBox</h4>
<select id="combobox"></select>
</div>
<script>
$(function() {
var combobox = $("#combobox").kendoComboBox({
dataTextField: "name",
dataValueField: "value",
dataSource: {
data: [{ name: "One", value: 1 }, { name: "Two", value: 2 }]
}
}).data('kendoComboBox');
//Filter the source manually
combobox.dataSource.filter({
field: 'value',
operator: 'eq',
value: 1
});
<!-- IMPORTANT: Update filter state of the widget -->
combobox.listView.setDSFilter(combobox.dataSource.filter());
combobox.value(1);
});
</script>
</div>
See Also
- ComboBox JavaScript API Reference
- How to Bypass Boundary Detection
- How to Configure Deferred Value Binding
- How to Expand ComboBox Located in Bootstrap Layout
- How to Implement Cascading with Local Data
- How to Make Visible Input Readonly
- How to Open ComboBox When onFocus is Triggered
- How to Prevent Adding Custom Values
- How to Select Items on Tab
- How to Underline Matched Search
For more runnable examples on the Kendo UI ComboBox, check its how-to articles.