Kendo UI 当用户没有select 建议中的选项时自动完成

Kendo UI Auto Complete when user does not select an option from the suggestions

使用 Kendo UI Autocomplete with filter: 'contains' and suggest: true if the user types-in a value that causes a match in the middle (say kingdom in the demo) and tabs out, the value becomes kingdom and not United Kingdom as one would expect. This causes data entry errors. Anyway to enforce the desired behavior? We want the users to be able to type-in anything if they could not find any option so mandating a selection isn't an option but we want the users to be able to pick a selection once they find it rather than current behavior where if the tab, they lose the found selection unless they select it manually... something like if they typed in the value that matches in the starting (e.g. united in the demo) 并跳出时。使用 contains 而不是 startsWith 的匹配也是可取的。

由于 Kendo UI 自动完成允许自定义值(您说要保留的行为),小部件没有 built-in 区分方式自定义值,以及您希望从列表中 select 的匹配项(如示例中 - 当用户键入 "united" 并按 TAB 键时,他可能只是希望小部件具有值 "united", 不一定 "United Kingdom").

您可以通过实现一些自定义 "blur" 事件处理程序来实现所需的行为,并且自动完成的 setting the value 是列表中的一个,例如,如果列表的长度为 1当用户按下 TAB 或以其他方式模糊小部件的输入时,例如:

Modified example