I have an used multi column sfcombobox with Autofilter (filterType.contain) feature. It works fine. but I would like to know below 2 point for easy filter.
1. "Syncfusion.Blazor.DropDowns.FilterType.Contains" filter only "Text" properties (highlighted in below code). I would like to know how to filter value in all column.
<SfComboBox Enabled="@EditEnabled" @ref="cmbMaterialSKU" FilterType="Syncfusion.Blazor.DropDowns.FilterType.Contains" Query="@query" TValue="int?" TItem="MaterialSKUSearchSetup" @bind-Value="@MaterialSKUID" CssClass="e-multi-column" AllowFiltering="true" PopupWidth="700px" @onkeypress="@keydown" EnableVirtualization="true">
<SfDataManager Json="@materialSKUSearchSetups" Adaptor="Adaptors.JsonAdaptor"></SfDataManager>
<ComboBoxFieldSettings Text="MaterialSKUName" Value="MaterialSKUID"></ComboBoxFieldSettings>
<ComboBoxEvents TValue="int?" TItem="MaterialSKUSearchSetup" ValueChange="@MaterialSKUChange"></ComboBoxEvents>
<ComboBoxTemplates TItem="MaterialSKUSearchSetup">
<HeaderTemplate>
<table><tr><th class="e-text-center">MaterialName</th><th width="100px">Source</th><th width="240px">MaterialCode</th></tr></table>
</HeaderTemplate>
<ItemTemplate Context="context2">
<table><tbody><tr><td style="height:none" class="e-text-center">@((context2 as MaterialSKUSearchSetup).MaterialSKUName)</td><td width="100px">@((context2 as MaterialSKUSearchSetup).SourceName)</td><td width="240px">@((context2 as MaterialSKUSearchSetup).MaterialSKUCode)</td></tr> </tbody></table>
</ItemTemplate>
</ComboBoxTemplates>
</SfComboBox>
2.How to filter value using concatenate string
For example :-
Original string is = Buckle Oval Buckle Antique Black
I would like to filter above string as
Buckle + Black
Note:-
concatenate string filter (+ operator) is available in devexpress .I would like to know how to use this in syncfussion combobox
Hi Kins,
Currently, we are validating on your reported query. we will update you the further details in two business days on or before 20th January 2022.
Regards,
Vinitha
|
<SfComboBox @ref="autoObj" ID="autocomplete" TValue="string" TItem="Games" Placeholder="e.g. Australia" DataSource="@LocalData">
<ComboBoxFieldSettings Text="Text" Value="ID"></ComboBoxFieldSettings>
<ComboBoxEvents Filtering="@OnFiltering" TValue="string" TItem="Games"></ComboBoxEvents>
</SfComboBox>
@code {
SfComboBox<string, Games> autoObj;
public Query query;
public class Games
{
public string ID { get; set; }
public string Text { get; set; }
}
List<Games> LocalData = new List<Games> {
new Games() { ID= "Game1", Text= "American Football" },
new Games() { ID= "Game2", Text= "Badminton" },
new Games() { ID= "Game3", Text= "Basketball" },
new Games() { ID= "Game4", Text= "Cricket" },
new Games() { ID= "Game5", Text= "Football" },
new Games() { ID= "Game6", Text= "Golf" },
new Games() { ID= "Game7", Text= "Hockey" },
new Games() { ID= "Game8", Text= "Rugby"},
new Games() { ID= "Game9", Text= "Snooker" },
new Games() { ID= "Game10", Text= "Tennis"},
};
public async Task OnFiltering(FilteringEventArgs e)
{
e.PreventDefaultAction = true;
query = new Query().Where(new WhereFilter()
{
Field = "ID",
value = e.Text,
Operator = "startswith",
IgnoreCase = true
});
await this.autoObj.Filter(LocalData, query);
}
}
|
Thanks for reply..
The above code will work for ID Column only,I would like to know how to filter other column.
| public async Task OnFiltering(FilteringEventArgs args)
{
e.PreventDefaultAction = true;
var pre = new WhereFilter();
var predicate = new List<WhereFilter>();
predicate.Add(new WhereFilter() { Condition = "or", Field = "ID", value = args.Text, Operator = "contains", IgnoreAccent = true, IgnoreCase = true });
predicate.Add(new WhereFilter() { Condition = "or", Field = "Text", value = args.Text, Operator = "contains", IgnoreAccent = true, IgnoreCase = true });
pre = WhereFilter.Or(predicate); var query = new Query().Where(pre); await this.autoObj.Filter(LocalData, query); } |
Can you please provide me example code for string concatenation "+" for custom filter in "Filtering event"
|
public async Task OnFiltering(FilteringEventArgs args)
{
args.PreventDefaultAction = true;
var splitWord = new string[] {};
if (args.Text.IndexOf("+") > 0)
{
splitWord = args.Text.Split("+");
}
var pre = new WhereFilter();
var predicate = new List<WhereFilter>();
if (splitWord.Length > 0)
{
predicate.Add(new WhereFilter() { Condition = "and", Field = "Text", value = splitWord[0], Operator = "contains", IgnoreAccent = true, IgnoreCase = true });
predicate.Add(new WhereFilter() { Condition = "and", Field = "Text", value = splitWord[1], Operator = "contains", IgnoreAccent = true, IgnoreCase = true });
}
else
{
predicate.Add(new WhereFilter() { Condition = "or", Field = "ID", value = args.Text, Operator = "contains", IgnoreAccent = true, IgnoreCase = true });
predicate.Add(new WhereFilter() { Condition = "or", Field = "Text", value = args.Text, Operator = "contains", IgnoreAccent = true, IgnoreCase = true });
}
pre = WhereFilter.Or(predicate);
var query = new Query().Where(pre);
await this.autoObj.Filter(LocalData, query);
} |