Unplanned
Last Updated: 05 May 2020 13:20 by ADMIN
Doug
Created on: 05 May 2020 13:19
Category: ComboBox
Type: Feature Request
1
Make the ComboBox work with both "suggest:true" and "filter:'contains'" configurations simultaneously

Currently, the "suggest" option of the ComboBox is designed to work only in a combination with 'filter:"startswith"'. If you open this Dojo and enter "T' in the ComboBox, then focus the ComboBox out then the "Two" ComboBox item will be selected.

If in the above demo, we change the filter configuration to "contains", when we enter "T" and focus the ComboBox out, the behavior will be the same, and "Two" will be selected. If we instead of "T" enter "w" and focus the ComboBox out then "two" won't be selected. To make the "Two" item selected, with "filter:'contains'" configuration, we can use the below workaround.

No matter the below workaround, it will be very useful if the below logic or similar one can be built-in in the ComboBox component.

<input id="combobox" />
<script>
var fruit = [
    {code: 1, name: "One" },
    {code: 2, name: "Two"},
    {code: 3, name: "Three"}
];

var ds = new kendo.data.DataSource({
data: fruit
});

$("#combobox").kendoComboBox({
  dataTextField: "name",
  dataValueField: "code",
   suggest: true,
   filter: "contains",
  dataSource: ds,
  change: function(e) {
    var comboBox = $("#combobox").data("kendoComboBox");
    var dataItem = comboBox.dataItem();
    if (dataItem === undefined) {
//special code for mobile browsers to auto select the first entry
if (comboBox.text() != "") {
ds.filter({ field: "name", operator:"contains", value: comboBox.text() });
if (ds.view().length > 0) {
comboBox.select(function(dataItem) {
return dataItem.name === ds.view()[0].name;
});
}
}
    }
  }
});
</script>
<input id="fred">

 

0 comments