Search results

Filtering

The AutoComplete has built-in support to filter data items. The filter operation starts as soon as you start typing characters in the component.

Change the filter type

Determines on which filter type the component needs to be considered on search action. The available FilterType and its supported data types are:

Filter Type Description
StartsWith Checks whether a value begins with the specified value.
EndsWith Checks whether a value ends with specified value.
Contains Checks whether a value contains with specified value.

The following examples shows data filtering is done with the StartsWith type.

@using Syncfusion.EJ2.Blazor.Data
@using Syncfusion.EJ2.Blazor.DropDowns

<EjsAutoComplete TValue="string"  Placeholder="Select a customer" Query="@Query" FilterType="Syncfusion.EJ2.Blazor.DropDowns.FilterType.StartsWith">
    <EjsDataManager Url="https://services.odata.org/V4/Northwind/Northwind.svc/" Adaptor="Adaptors.ODataV4Adaptor" CrossDomain=true></EjsDataManager>
    <AutoCompleteFieldSettings Value="ContactName"></AutoCompleteFieldSettings>
</EjsAutoComplete>

@code {
    public string Query = "new ej.data.Query().from('Customers').select(['ContactName', 'CustomerID']).requiresCount()";
}

The output will be as follows.

AutoComplete

Filter item count

You can specify the filter suggestion item count using the SuggestionCount property of AutoComplete.

Refer to the following example to restrict the suggestion list item counts as 3.

@using Syncfusion.EJ2.Blazor.Data
@using Syncfusion.EJ2.Blazor.DropDowns

<EjsAutoComplete TValue="string"  Placeholder="Select a customer" Query="@Query" SuggestionCount=3 FilterType="Syncfusion.EJ2.Blazor.DropDowns.FilterType.StartsWith">
    <EjsDataManager Url="https://services.odata.org/V4/Northwind/Northwind.svc/" Adaptor="Adaptors.ODataV4Adaptor" CrossDomain=true></EjsDataManager>
    <AutoCompleteFieldSettings Value="ContactName"></AutoCompleteFieldSettings>
</EjsAutoComplete>

@code {

    public string Query = "new ej.data.Query().from('Customers').select(['ContactName', 'CustomerID']).requiresCount()";
}

The output will be as follows.

AutoComplete

Limit the minimum filter character

You can set the limit for the character count to filter the data on the AutoComplete. This can be done by setting the MinLength property to AutoComplete.

In the following example, the remote request doesn’t fetch the search data until the search key contains three characters.

@using Syncfusion.EJ2.Blazor.Data
@using Syncfusion.EJ2.Blazor.DropDowns

<EjsAutoComplete TValue="string"  Placeholder="Select a customer" Query="@Query" MinLength=3 FilterType="Syncfusion.EJ2.Blazor.DropDowns.FilterType.StartsWith">
    <EjsDataManager Url="https://services.odata.org/V4/Northwind/Northwind.svc/" Adaptor="Adaptors.ODataV4Adaptor" CrossDomain=true></EjsDataManager>
    <AutoCompleteFieldSettings Value="ContactName"></AutoCompleteFieldSettings>
</EjsAutoComplete>

@code {

    public string Query = "new ej.data.Query().from('Customers').select(['ContactName', 'CustomerID']).requiresCount()";
}

The output will be as follows.

AutoComplete

Case sensitive filtering

Data items can be filtered either with or without case sensitivity using the DataManager. This can be done by setting the IgnoreCase property of AutoComplete.

The following sample depicts how to filter the data with case-sensitive.

@using Syncfusion.EJ2.Blazor.Data
@using Syncfusion.EJ2.Blazor.DropDowns

<EjsAutoComplete TValue="string"  Placeholder="Select a customer" Query="@Query" IgnoreCase=false FilterType="Syncfusion.EJ2.Blazor.DropDowns.FilterType.StartsWith">
    <EjsDataManager Url="https://services.odata.org/V4/Northwind/Northwind.svc/" Adaptor="Adaptors.ODataV4Adaptor" CrossDomain=true></EjsDataManager>
    <AutoCompleteFieldSettings Value="ContactName"></AutoCompleteFieldSettings>
</EjsAutoComplete>

@code {

    public string Query = "new ej.data.Query().from('Customers').select(['ContactName', 'CustomerID']).requiresCount()";
}

Diacritics filtering

An AutoComplete supports diacritics filtering, which will ignore the Diacritics and makes it easier to filter the results in international characters lists when the IgnoreAccent is enabled.

In the following sample, data with diacritics are bound as dataSource for AutoComplete.

@using Syncfusion.EJ2.Blazor.Data
@using Syncfusion.EJ2.Blazor.DropDowns

<EjsAutoComplete TValue="string" Placeholder="e.g: Aero" IgnoreAccent=true DataSource="@Country">
    <AutoCompleteFieldSettings Value="Name"></AutoCompleteFieldSettings>
</EjsAutoComplete>

@code {

    public class Data
    {
        public string Name { get; set; }
    }

    List<Data>Country = new List<Data>
    {
        new Data() { Name = "Aeróbics"},
        new Data() { Name = "Aeróbics en Agua"},
        new Data() { Name = "Aerografía"},
        new Data() { Name = "Águilas"},
        new Data() { Name = "Ajedrez"},
        new Data() { Name = "Ala Delta"},
        new Data() { Name = "Álbumes de Música"},
        new Data() { Name = "Alusivos"},
        new Data() { Name = "Análisis de Escritura a Mano"},
    };
}