Hello there,
I am trying to set up a filter query in dropdownlistt that splits up each word and looks at them both and if both words exist in results then show those results.
The problem iI think I m running into is the query filters what i want but is still also looking for the value that is in the dropdown box filter.
Example: If I have an item which is TWTH - Extension Course English and I type in the filter box TWTH Extension course it wont show up even though my filter is doing the following:
public async Task FilterList(FilteringEventArgs args)
{
var text = args.Text.Split(" ", StringSplitOptions.TrimEntries);
string querystring = "";
var Col1Pre = new WhereFilter();
var predicate = new List<WhereFilter>();
args.PreventDefaultAction = true;
if (text.Count() == 1 || text.Count() == 2 && string.IsNullOrEmpty(text[1]))
{
predicate.Add(new WhereFilter() { Field = "Description", Operator = "contains", value = text[0], IgnoreCase = true });
}
else if (text.Count() == 2 || text.Count() == 3 && string.IsNullOrEmpty(text[2]))
{
predicate.Add(new WhereFilter() { Field = "Description", Operator = "contains", value = text[0], IgnoreCase = true});
predicate.Add(new WhereFilter() { Field = "Description", Operator = "contains", value = text[1], IgnoreCase = true});
}
else if (text.Count() == 3 || text.Count() == 4 && string.IsNullOrEmpty(text[3]))
{
predicate.Add(new WhereFilter() { Field = "Description", Operator = "contains", value = text[0], IgnoreCase = true});
predicate.Add(new WhereFilter() { Field = "Description", Operator =
"contains", value = text[1], IgnoreCase = true});
predicate.Add(new WhereFilter() { Field = "Description", Operator = "contains", value = text[2], IgnoreCase = true});
}
else if (text.Count() == 4 || text.Count() == 5 && string.IsNullOrEmpty(text[4]))
{
predicate.Add(new WhereFilter() { Field = "Description", Operator = "contains", value = text[0], IgnoreCase = true});
predicate.Add(new WhereFilter() { Field = "Description", Operator =
"contains", value = text[1], IgnoreCase = true});
predicate.Add(new WhereFilter() { Field = "Description", Operator = "contains", value = text[2], IgnoreCase = true});
predicate.Add(new WhereFilter() { Field = "Description", Operator =
"contains", value = text[3], IgnoreCase = true});
}
Col1Pre = WhereFilter.And(predicate);
Query = new Query().Where(Col1Pre).Take(40).Distinct(Description);
//await SfComboBox.Filter(ItemsList, Query);
//Description = data.GetItems().Where(p => EF.Functions.Like(p.Description, "%" + args.Text + "%")).Select(p => p.Description).Distinct().Take(20).ToList();
}