I am currently having some issues with Kendo UI. At the moment I have a autocomplete which I use to get employees. The issue I am having is I would like to be able to get the autocomplete to work with multiple words (first and last name) e.g 'John Smith'. Currently I have the autocomplete working fine if 'john' is typed in it would show 'John smith' in the dropdown below along with other names containing the word 'john'. The same works ok if I type in the surname 'smith' and have the option of selecting 'john smith'. What I am trying to do is, when the whole name is typed in 'John Smith' allow the user to select John smith, this meaning it still does a search on the two words. Can anyone help? I will put my code below.
Thanks.
//Autocomplete FeeEarner
$("#FeeEarnerEmailSend").kendoAutoComplete({
dataSource: new kendo.data.DataSource({
serverFiltering: true,
transport: {
read: "/" + prefix + "/api/Session/GetEmployees",
parameterMap: function () {
return { id: $("#FeeEarnerEmailSend").data("kendoAutoComplete").value() };
}
}
}),
dataTextField: 'FullName',
filter: "contains",
//placeholder: "Search...",
minLength: 3,
suggest: true,
select: function (e) {
var employeeAutoComplete = e.sender;
// this var is used in the Search button click event
selectedEmployeeDataItem = employeeAutoComplete.dataItem(e.item.index());
},
change: function () {
if ($.trim($("#FeeEarnerEmailSend").val()) == "") {
selectedEmployeeDataItem = null;
}
},
dataBound: function (e) {
selectedEmployeeDataItem = e.sender.dataItem(0);
}
});
What I understood from your question is you want to select the name until the full name is typed. This depends upon the "filter" and "minLength" property of auto-complete widget.
Filters that are supported by kendo auto-complete are: startswith, endswith and contains.
minLength:- It depends on requirement that after entering how many characters the filtration should start. If this is removed the filtration starts immediately after entering a character.
As the name are of different length so I do fear that filtering name using minLength can fulfill your requirement. Also same with "filter" property as it don't support anything like "exact match".(default = 1).
So, its upto you that how wisely you use this two properties to achieve your goal.
Hope this helps.