menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class AutoCompleteEvents<TValue, TItem> - Blazor API Reference | Syncfusion

    Show / Hide Table of Contents

    Class AutoCompleteEvents<TValue, TItem>

    Represents the event handlers for the SfAutoComplete<TValue, TItem> component in the Blazor framework.

    Inheritance
    System.Object
    AutoCompleteEvents<TValue, TItem>
    Namespace: Syncfusion.Blazor.DropDowns
    Assembly: Syncfusion.Blazor.dll
    Syntax
    public class AutoCompleteEvents<TValue, TItem> : OwningComponentBase
    Type Parameters
    Name Description
    TValue

    The type of value associated with the AutoComplete component.

    TItem

    The type of item associated with the AutoComplete component.

    Constructors

    AutoCompleteEvents()

    Declaration
    public AutoCompleteEvents()

    Properties

    Blur

    Gets or sets the event callback invoked when the SfAutoComplete<TValue, TItem> component loses focus.

    Declaration
    public EventCallback<object> Blur { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<System.Object>

    An Microsoft.AspNetCore.Components.EventCallback<> that is triggered when the component loses focus.

    Remarks

    This event is useful for performing actions when the user navigates away from the AutoComplete input, such as validating input or updating other components.

    Examples
    <SfAutoComplete TItem="string" TValue="string" DataSource="@MyList">
        <AutoCompleteEvents TValue="string" TItem="string" Blur="@OnBlurHandler"/>
    </SfAutoComplete>
    @code {
        protected List<string> MyList = new List<string>() { "Small", "Medium", "Large" };
        public void OnBlurHandler(object args) {
            // Handle blur event
        }
    }

    Closed

    Gets or sets the event callback invoked after the suggestions popup has been closed.

    Declaration
    public EventCallback<ClosedEventArgs> Closed { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<ClosedEventArgs>

    An Microsoft.AspNetCore.Components.EventCallback<> that is triggered after the suggestions popup is closed.

    Remarks

    This event is useful for performing actions after the suggestions popup is closed, such as updating the component state or triggering related UI updates.

    Examples
    <SfAutoComplete TItem="string" TValue="string" DataSource="@MyList">
        <AutoCompleteEvents TValue="string" TItem="string" Closed="@OnClosedHandler"/>
    </SfAutoComplete>
    @code {
        protected List<string> MyList = new List<string>() { "Small", "Medium", "Large" };
        public void OnClosedHandler(ClosedEventArgs args) {
            // Handle popup closed event
        }
    }

    Created

    Gets or sets the event callback invoked when the SfAutoComplete<TValue, TItem> component is created.

    Declaration
    public EventCallback<object> Created { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<System.Object>

    An Microsoft.AspNetCore.Components.EventCallback<> that is triggered when the component is initialized.

    Remarks

    This event is useful for performing initialization tasks or setting up component state when the AutoComplete is first created.

    Examples
    <SfAutoComplete TItem="string" TValue="string" DataSource="@MyList">
        <AutoCompleteEvents TValue="string" TItem="string" Created="@OnCreatedHandler"/>
    </SfAutoComplete>
    @code {
        protected List<string> MyList = new List<string>() { "Small", "Medium", "Large" };
        public void OnCreatedHandler(object args) {
            // Handle component creation
        }
    }

    CustomValueSpecifier

    Gets or sets the event callback for handling custom value specification in the SfAutoComplete<TValue, TItem> component.

    Declaration
    public EventCallback<CustomValueSpecifierEventArgs<TItem>> CustomValueSpecifier { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<CustomValueSpecifierEventArgs<TItem>>

    An EventCallback<CustomValueSpecifierEventArgs<TItem>> that is triggered when a custom value is specified.

    Remarks

    This event allows customization of how custom values (not present in the data source) are handled when entered by the user.

    Examples
    <SfAutoComplete TItem="string" TValue="string" DataSource="@MyList">
        <AutoCompleteEvents TValue="string" TItem="string" CustomValueSpecifier="@OnCustomValueHandler"/>
    </SfAutoComplete>
    @code {
        protected List<string> MyList = new List<string>() { "Small", "Medium", "Large" };
        public void OnCustomValueHandler(CustomValueSpecifierEventArgs<string> args) {
            // Handle custom value
        }
    }

    DataBound

    Gets or sets the event callback invoked when the data source is populated in the suggestion list.

    Declaration
    public EventCallback<DataBoundEventArgs> DataBound { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<DataBoundEventArgs>

    An Microsoft.AspNetCore.Components.EventCallback<> that is triggered when the suggestion list is populated with data.

    Remarks

    This event is useful for performing actions after the data source has been bound to the suggestion list, such as modifying the displayed items.

    Examples
    <SfAutoComplete TItem="string" TValue="string" DataSource="@MyList">
        <AutoCompleteEvents TValue="string" TItem="string" DataBound="@OnDataBoundHandler"/>
    </SfAutoComplete>
    @code {
        protected List<string> MyList = new List<string>() { "Small", "Medium", "Large" };
        public void OnDataBoundHandler(DataBoundEventArgs args) {
            // Handle data bound event
        }
    }

    Destroyed

    Gets or sets the event callback invoked when the SfAutoComplete<TValue, TItem> component is destroyed.

    Declaration
    public EventCallback<object> Destroyed { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<System.Object>

    An Microsoft.AspNetCore.Components.EventCallback<> that is triggered when the component is destroyed.

    Remarks

    This event is useful for performing cleanup tasks when the AutoComplete component is removed from the UI.

    Examples
    <SfAutoComplete TItem="string" TValue="string" DataSource="@MyList">
        <AutoCompleteEvents TValue="string" TItem="string" Destroyed="@OnDestroyedHandler"/>
    </SfAutoComplete>
    @code {
        protected List<string> MyList = new List<string>() { "Small", "Medium", "Large" };
        public void OnDestroyedHandler(object args) {
            // Handle component destruction
        }
    }

    Filtering

    Gets or sets the event callback invoked when a character is typed in the SfAutoComplete<TValue, TItem> component.

    Declaration
    public EventCallback<FilteringEventArgs> Filtering { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<FilteringEventArgs>

    An Microsoft.AspNetCore.Components.EventCallback<> that is triggered when the user types a character in the AutoComplete input.

    Remarks

    This event allows customization of the filtering process by setting FilteringEventArgs.PreventDefaultAction to true and passing a modified data source and query to the FilterAsync(IEnumerable<TItem>, Query, FieldSettingsModel) method.

    Examples
    <SfAutoComplete @ref="AutoCompleteObj" TItem="string" TValue="string" AllowFiltering="true" DataSource="@MyList">
        <AutoCompleteEvents TValue="string" TItem="string" Filtering="@OnFilteringHandler"/>
    </SfAutoComplete>
    @code {
        SfAutoComplete<string, string> AutoCompleteObj { get; set; }
        protected List<string> MyList = new List<string>() { "Small", "Medium", "Large" };
        public async Task OnFilteringHandler(FilteringEventArgs args) {
            args.PreventDefaultAction = true;
            var query = new Query().Where(new WhereFilter() { Field = "Text", Operator = "contains", value = args.Text, IgnoreCase = true });
            await AutoCompleteObj.FilterAsync(MyList, query);
        }
    }

    Focus

    Gets or sets the event callback invoked when the SfAutoComplete<TValue, TItem> component gains focus.

    Declaration
    public EventCallback<object> Focus { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<System.Object>

    An Microsoft.AspNetCore.Components.EventCallback<> that is triggered when the component receives focus.

    Remarks

    This event is useful for performing actions when the user focuses on the AutoComplete input, such as initializing or updating component state.

    Examples
    <SfAutoComplete TItem="string" TValue="string" DataSource="@MyList">
        <AutoCompleteEvents TValue="string" TItem="string" Focus="@OnFocusHandler"/>
    </SfAutoComplete>
    @code {
        protected List<string> MyList = new List<string>() { "Small", "Medium", "Large" };
        public void OnFocusHandler(object args) {
            // Handle focus event
        }
    }

    OnActionBegin

    Gets or sets the event callback invoked before fetching data from the data source.

    Declaration
    public EventCallback<ActionBeginEventArgs> OnActionBegin { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<ActionBeginEventArgs>

    An Microsoft.AspNetCore.Components.EventCallback<> that is triggered before the data fetch operation begins.

    Remarks

    This event allows customization of the data retrieval process before it starts. You can use it to modify query parameters or cancel the data fetch operation.

    Examples
    <SfAutoComplete TItem="string" TValue="string" DataSource="@MyList">
        <AutoCompleteEvents TValue="string" TItem="string" OnActionBegin="@OnActionBeginHandler"/>
    </SfAutoComplete>
    @code {
        protected List<string> MyList = new List<string>() { "Small", "Medium", "Large" };
        public void OnActionBeginHandler(ActionBeginEventArgs args) {
            // Customize query or cancel data fetch
        }
    }

    OnActionComplete

    Gets or sets the event callback invoked after data is successfully fetched from the data source.

    Declaration
    public EventCallback<ActionCompleteEventArgs<TItem>> OnActionComplete { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<ActionCompleteEventArgs<TItem>>

    An EventCallback<ActionCompleteEventArgs<TItem>> that is triggered after the data fetch operation completes successfully.

    Remarks

    This event is useful for processing or modifying the fetched data before it is displayed in the suggestion list.

    Examples
    <SfAutoComplete TItem="string" TValue="string" DataSource="@MyList">
        <AutoCompleteEvents TValue="string" TItem="string" OnActionComplete="@OnActionCompleteHandler"/>
    </SfAutoComplete>
    @code {
        protected List<string> MyList = new List<string>() { "Small", "Medium", "Large" };
        public void OnActionCompleteHandler(ActionCompleteEventArgs<string> args) {
            // Process fetched data
        }
    }

    OnActionFailure

    Gets or sets the event callback invoked when the data fetch request fails.

    Declaration
    public EventCallback<Exception> OnActionFailure { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<System.Exception>

    An Microsoft.AspNetCore.Components.EventCallback<> that is triggered when the data fetch operation encounters an error.

    Remarks

    This event allows handling of errors that occur during data retrieval, such as network issues or invalid data sources.

    Examples
    <SfAutoComplete TItem="string" TValue="string" DataSource="@MyList">
        <AutoCompleteEvents TValue="string" TItem="string" OnActionFailure="@OnActionFailureHandler"/>
    </SfAutoComplete>
    @code {
        protected List<string> MyList = new List<string>() { "Small", "Medium", "Large" };
        public void OnActionFailureHandler(Exception ex) {
            // Handle fetch failure
        }
    }

    OnClose

    Gets or sets the event callback invoked before the suggestions popup is closed.

    Declaration
    public EventCallback<PopupEventArgs> OnClose { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<PopupEventArgs>

    An Microsoft.AspNetCore.Components.EventCallback<> that is triggered before the suggestions popup closes.

    Remarks

    This event allows cancellation of the popup closing by setting Cancel to true, keeping the popup open.

    Examples
    <SfAutoComplete TItem="string" TValue="string" DataSource="@MyList">
        <AutoCompleteEvents TValue="string" TItem="string" OnClose="@OnCloseHandler"/>
    </SfAutoComplete>
    @code {
        protected List<string> MyList = new List<string>() { "Small", "Medium", "Large" };
        public void OnCloseHandler(PopupEventArgs args) {
            args.Cancel = true;
        }
    }

    OnOpen

    Gets or sets the event callback invoked before the suggestions popup opens.

    Declaration
    public EventCallback<BeforeOpenEventArgs> OnOpen { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<BeforeOpenEventArgs>

    An Microsoft.AspNetCore.Components.EventCallback<> that is triggered before the suggestions popup is displayed.

    Remarks

    This event allows cancellation of the popup opening by setting Cancel to true, preventing the suggestions list from appearing.

    Examples
    <SfAutoComplete TItem="string" TValue="string" DataSource="@MyList">
        <AutoCompleteEvents TValue="string" TItem="string" OnOpen="@OnOpenHandler"/>
    </SfAutoComplete>
    @code {
        protected List<string> MyList = new List<string>() { "Small", "Medium", "Large" };
        public void OnOpenHandler(BeforeOpenEventArgs args) {
            args.Cancel = true;
        }
    }

    OnValueSelect

    Gets or sets the event callback invoked when an item is selected from the suggestions popup by the user.

    Declaration
    public EventCallback<SelectEventArgs<TItem>> OnValueSelect { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<SelectEventArgs<TItem>>

    An EventCallback<SelectEventArgs<TItem>> that is triggered when an item is selected using mouse or keyboard navigation.

    Remarks

    This event allows cancellation of the item selection by setting SelectEventArgs<TItem>.Cancel to true. It is triggered when the user selects an item from the suggestion popup via mouse click or keyboard navigation.

    Examples
    <SfAutoComplete TItem="string" TValue="string" DataSource="@MyList">
        <AutoCompleteEvents TValue="string" TItem="string" OnValueSelect="@OnSelectHandler"/>
    </SfAutoComplete>
    @code {
        protected List<string> MyList = new List<string>() { "Small", "Medium", "Large" };
        public void OnSelectHandler(SelectEventArgs<string> args) {
            if (args.ItemData == "Medium")
                args.Cancel = true;
        }
    }

    Opened

    Gets or sets the event callback invoked when the suggestions popup opens.

    Declaration
    public EventCallback<PopupEventArgs> Opened { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<PopupEventArgs>

    An Microsoft.AspNetCore.Components.EventCallback<> that is triggered when the suggestions popup is fully opened.

    Remarks

    This event allows you to perform actions after the suggestions popup is displayed, such as updating the UI or logging the event.

    Examples
    <SfAutoComplete TItem="string" TValue="string" DataSource="@MyList">
        <AutoCompleteEvents TValue="string" TItem="string" Opened="@OnOpenedHandler"/>
    </SfAutoComplete>
    @code {
        protected List<string> MyList = new List<string>() { "Small", "Medium", "Large" };
        public void OnOpenedHandler(PopupEventArgs args) {
            // Handle popup opened event
        }
    }

    ValueChange

    Gets or sets the event callback invoked when the value of the SfAutoComplete<TValue, TItem> component changes.

    Declaration
    public EventCallback<ChangeEventArgs<TValue, TItem>> ValueChange { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<ChangeEventArgs<TValue, TItem>>

    An EventCallback<ChangeEventArgs<TValue, TItem>> that is triggered when an item is selected from the popup or the model value changes.

    Remarks

    This event is triggered when an item in the suggestion popup is selected or when the user programmatically changes the model value. It provides access to the new and previous values for further processing. Use args.Value in the event arguments to get the current value.

    Examples
    <SfAutoComplete TItem="string" TValue="string" DataSource="@MyList">
        <AutoCompleteEvents TValue="string" TItem="string" ValueChange="@OnChange"/>
    </SfAutoComplete>
    @code {
        protected List<string> MyList = new List<string>() { "Small", "Medium", "Large" };
        public void OnChange(Syncfusion.Blazor.DropDowns.ChangeEventArgs<string, string> args) {
            var NewValue = args.Value;
        }
    }

    Methods

    ComponentDispose(Boolean)

    Disposes of the AutoCompleteEvents<TValue, TItem> component resources.

    Declaration
    protected void ComponentDispose(bool disposing)
    Parameters
    Type Name Description
    System.Boolean disposing

    A boolean indicating whether the component is being disposed.

    Remarks

    This method is called during component disposal to clean up resources, such as clearing the reference to the parent SfAutoComplete<TValue, TItem> component when disposing is true.

    OnInitializedAsync()

    Triggers during the initial rendering of the AutoCompleteEvents<TValue, TItem> component.

    Declaration
    protected override Task OnInitializedAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing the asynchronous initialization operation.

    Remarks

    This method is called when the component is first initialized, setting up the necessary event handlers and linking to the parent SfAutoComplete<TValue, TItem> component.

    Exceptions
    Type Condition
    System.Exception

    Thrown if an error occurs during initialization.

    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved