FYI - Minor error thrown in Console with AutoComplete if DataSource is null

I was working with the AutoComplete component at a beginning phase where I did not yet have a need for a data source, so my intention was for the component to act like a basic text box for the time being.

I found that not setting anything for a DataSource causes the component to throw a console error when typing something in and clicking a non character key like "Enter"






I feel that likely this is expected behavior if AutoComplete always expects to have a DataSource set.

But I wanted to mention it just in case someone else ran in to this phenomenon.


Attachment: AutoCompleteTest_Simple_81e997c5.zip

2 Replies

UD UdhayaKumar Duraisamy Syncfusion Team April 25, 2022 04:03 PM UTC

Hi Sorin,


We are validating the requirement. We will update the further details in two business days (27th April
2022).



Regards,

Udhaya Kumar D




UD UdhayaKumar Duraisamy Syncfusion Team April 26, 2022 06:53 AM UTC

Hi Sorin,


We have prepared a sample for the requirement and attached it below for reference. We suggest you to use a filtering event to set the datasource and perform filtering. We also attached the documentation for further reference.


 

<h2>AutoComplete with null DataSource</h2>

<div>

    <SfAutoComplete TValue="string" TItem="string" @ref="@AutocompleteObj" @bind-Value="SearchValue" > 

        <AutoCompleteEvents TValue="string" TItem="string" Filtering="OnFilter"></AutoCompleteEvents>

    </SfAutoComplete>

</div>

 

@code

{

    SfAutoComplete<string, string> AutocompleteObj { get; set; }

 

    [Parameter] public string SearchValue { get; set; } = "";

    [Parameter] public string SearchValue2 { get; set; } = "";

 

    List<string> TempStringList = new List<string>()

    {

        "Australia", "Bermuda", "Canada","Cameroon"

    };

 

    private async Task OnFilter(FilteringEventArgs args)

    {

        args.PreventDefaultAction = true;

        var query = new Query().Where(new WhereFilter() { Field = "TempStringList", Operator = "contains", value = args.Text, IgnoreCase = true });

        await AutocompleteObj.FilterAsync(TempStringList, query);

    }

}

 


Documentation : https://blazor.syncfusion.com/documentation/autocomplete/filtering#custom-filtering


Please get back to us if you need any further assistance on this.


Regards,

Udhaya Kumar D



Attachment: Autocomplete174586_f99bbd07.zip

Loader.
Up arrow icon