Actually, you can make the code to filter the list on server side before sending it to the client
Here is an example:
On the View page, overwrite the source by passing in additional parameter
function split(val) {
return val.split(/,\s*/);
}
function extractLast(term) {
return split(term).pop();
}
.autocomplete({
...
source: function (request, response) {
$.getJSON(
'YourController/Action',
{
term: extractLast(request.term),
sValue: $('#textBoxId').val()
},
response);
},
...
});
On the server side, add additional logic to filter out the selected value from the source
public JsonResult AutocompleteFilter(string term, string sValue)
{
string[] selectedValue =
sValue.Split(',').Select(s => s.ToLower().Trim()).ToArray();
var result = from o in yourSource
where !selectedValue.Contains(o.WhatEverField.ToLower())
&& ...
select o;
...
}
Resources:
jQuery UI autocomplete filter data - Stack Overflow[
^]
Autocomplete: Refactored code for array filtering into $.ui.autocompl… · jquery/jquery-ui@dbc9add · GitHub[
^]