Class ComboBoxEvents<TValue, TItem>
Defines event handlers for the SfComboBox<TValue, TItem> component in the Blazor framework.
Inheritance
Namespace: Syncfusion.Blazor.DropDowns
Assembly: Syncfusion.Blazor.dll
Syntax
public class ComboBoxEvents<TValue, TItem> : OwningComponentBase
Type Parameters
Name | Description |
---|---|
TValue | The type of the value associated with the ComboBox. |
TItem | The type of items associated with the ComboBox. |
Remarks
This class provides event callbacks for various interactions with the ComboBox, such as data fetching, selection, and popup events.
Examples
<SfComboBox TValue="string" TItem="string" DataSource="@MyList">
<ComboBoxEvents TValue="string" TItem="string" Created="@OnCreated" />
</SfComboBox>
@code {
protected List<string> MyList = new List<string> { "Apple", "Banana", "Orange" };
private void OnCreated(object args)
{
// Handle component creation
}
}
Constructors
ComboBoxEvents()
Declaration
public ComboBoxEvents()
Properties
Blur
Gets or sets the event callback invoked when the ComboBox 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 receives an System.Object when triggered. |
Remarks
This event is triggered when the ComboBox loses focus, enabling developers to perform actions such as validation or UI updates in response to the blur event.
Examples
<SfComboBox TItem="string" TValue="string" DataSource="@MyList">
<ComboBoxEvents TValue="string" TItem="string" Blur="@OnBlurHandler" />
</SfComboBox>
@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 dropdown popup is closed.
Declaration
public EventCallback<ClosedEventArgs> Closed { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<ClosedEventArgs> | An Microsoft.AspNetCore.Components.EventCallback<> that receives a ClosedEventArgs object when triggered. |
Remarks
This event is triggered after the dropdown popup is closed, allowing developers to perform post-closure actions such as updating the UI or processing the selected value.
Examples
<SfComboBox TValue="string" TItem="string" DataSource="@MyList">
<ComboBoxEvents TValue="string" TItem="string" Closed="@OnClosed" />
</SfComboBox>
@code {
protected List<string> MyList = new List<string> { "Apple", "Banana", "Orange" };
private void OnClosed(ClosedEventArgs args)
{
// Handle popup closed event
}
}
Created
Gets or sets the event callback invoked when the ComboBox 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 receives an System.Object when triggered. |
Remarks
This event is triggered after the ComboBox is initialized and rendered, allowing developers to perform setup or initialization tasks.
Examples
<SfComboBox TItem="string" TValue="string" DataSource="@MyList">
<ComboBoxEvents TValue="string" TItem="string" Created="@OnCreated" />
</SfComboBox>
@code {
protected List<string> MyList = new List<string> { "Small", "Medium", "Large" };
public void OnCreated(object args)
{
// Handle component creation
}
}
CustomValueSpecifier
Gets or sets the event callback invoked when a custom value not present in the data source is entered.
Declaration
public EventCallback<CustomValueSpecifierEventArgs<TItem>> CustomValueSpecifier { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<CustomValueSpecifierEventArgs<TItem>> | An Microsoft.AspNetCore.Components.EventCallback<> that receives a CustomValueSpecifierEventArgs<T> object when triggered. |
Remarks
This event is triggered when a user enters a value not present in the data source and AllowCustom is enabled. Developers can use this event to define the custom item to be added to the ComboBox.
Examples
<SfComboBox TValue="int" TItem="Countries" DataSource="@CountryList">
<ComboBoxEvents TValue="int" TItem="Countries" CustomValueSpecifier="@CustomValue" />
<ComboBoxFieldSettings Text="Name" Value="Code" />
</SfComboBox>
@code {
public class Countries
{
public string Name { get; set; }
public int Code { get; set; }
}
private List<Countries> CountryList = new List<Countries>
{
new Countries { Code = 101, Name = "Australia" },
new Countries { Code = 102, Name = "Canada" }
};
private void CustomValue(CustomValueSpecifierEventArgs<Countries> args)
{
args.Item = new Countries { Code = 103, Name = args.Text };
}
}
DataBound
Gets or sets the event callback invoked when the data source is populated in the popup list.
Declaration
public EventCallback<DataBoundEventArgs> DataBound { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<DataBoundEventArgs> | An Microsoft.AspNetCore.Components.EventCallback<> that receives a DataBoundEventArgs object when triggered. |
Remarks
This event is triggered after the data source is populated in the ComboBox popup, providing access to the loaded items for further processing.
Examples
<SfComboBox TItem="string" TValue="string" DataSource="@MyList">
<ComboBoxEvents TValue="string" TItem="string" DataBound="@OnDataBound" />
</SfComboBox>
@code {
protected List<string> MyList = new List<string> { "Small", "Medium", "Large" };
public void OnDataBound(DataBoundEventArgs args)
{
// Process populated data
}
}
Destroyed
Gets or sets the event callback invoked when the ComboBox is disposed.
Declaration
public EventCallback<object> Destroyed { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<System.Object> | An Microsoft.AspNetCore.Components.EventCallback<> that receives an System.Object when triggered. |
Remarks
This event is triggered when the ComboBox is disposed, allowing cleanup or finalization tasks to be performed.
Examples
<SfComboBox TItem="string" TValue="string" DataSource="@MyList">
<ComboBoxEvents TValue="string" TItem="string" Destroyed="@OnDestroyed" />
</SfComboBox>
@code {
protected List<string> MyList = new List<string> { "Small", "Medium", "Large" };
public void OnDestroyed(object args)
{
// Handle component destruction
}
}
Filtering
Gets or sets the event callback invoked when filtering is performed on the ComboBox data source.
Declaration
public EventCallback<FilteringEventArgs> Filtering { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<FilteringEventArgs> | An Microsoft.AspNetCore.Components.EventCallback<> that receives a FilteringEventArgs object when triggered. |
Remarks
This event is triggered when the user types in the ComboBox and filtering is enabled via the AllowFiltering
property. It allows developers to customize the filtering logic or cancel the default filtering action using Cancel or PreventDefaultAction.
Examples
<SfComboBox TValue="string" TItem="string" AllowFiltering="true" DataSource="@MyList">
<ComboBoxEvents TValue="string" TItem="string" Filtering="@OnFiltering" />
</SfComboBox>
@code {
protected List<string> MyList = new List<string> { "Apple", "Banana", "Orange" };
private void OnFiltering(FilteringEventArgs args)
{
// Customize filtering logic
args.PreventDefaultAction = true;
}
}
Focus
Gets or sets the event callback invoked when the ComboBox 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 receives an System.Object when triggered. |
Remarks
This event is triggered when the ComboBox input gains focus, allowing developers to perform actions such as UI updates or input preparation.
Examples
<SfComboBox TValue="string" TItem="string" DataSource="@MyList">
<ComboBoxEvents TValue="string" TItem="string" Focus="@OnFocus" />
</SfComboBox>
@code {
protected List<string> MyList = new List<string> { "Apple", "Banana", "Orange" };
private void OnFocus(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 receives an ActionBeginEventArgs object when triggered. |
Remarks
This event is fired before the ComboBox fetches data, allowing developers to modify the query or cancel the action via Cancel.
Examples
<SfComboBox TValue="string" TItem="string" DataSource="@MyList">
<ComboBoxEvents TValue="string" TItem="string" OnActionBegin="@OnActionBeginHandler" />
</SfComboBox>
@code {
protected List<string> MyList = new List<string> { "Apple", "Banana", "Orange" };
private void OnActionBeginHandler(ActionBeginEventArgs args)
{
// Modify query or cancel action
}
}
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 Microsoft.AspNetCore.Components.EventCallback<> that receives an ActionCompleteEventArgs<TItem> object when triggered. |
Remarks
This event is triggered after data is fetched, providing access to the fetched data and query via Result and Query. It allows cancellation of further processing via Cancel.
Examples
<SfComboBox TValue="string" TItem="string" DataSource="@MyList">
<ComboBoxEvents TValue="string" TItem="string" OnActionComplete="@OnActionCompleteHandler" />
</SfComboBox>
@code {
protected List<string> MyList = new List<string> { "Apple", "Banana", "Orange" };
private 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 receives an System.Exception object when triggered. |
Remarks
This event is triggered when a data fetch request fails, providing the exception details for error handling.
Examples
<SfComboBox TValue="string" TItem="string" DataSource="@MyList">
<ComboBoxEvents TValue="string" TItem="string" OnActionFailure="@OnActionFailureHandler" />
</SfComboBox>
@code {
protected List<string> MyList = new List<string> { "Apple", "Banana", "Orange" };
private void OnActionFailureHandler(Exception ex)
{
// Handle fetch failure
}
}
OnClose
Gets or sets the event callback invoked before the dropdown popup closes.
Declaration
public EventCallback<PopupEventArgs> OnClose { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<PopupEventArgs> | An Microsoft.AspNetCore.Components.EventCallback<> that receives a PopupEventArgs object when triggered. |
Remarks
This event is triggered before the dropdown popup closes, allowing cancellation of the close action via Cancel. If cancelled, the popup remains open, enabling developers to enforce specific conditions for closing.
Examples
<SfComboBox TItem="string" TValue="string" DataSource="@MyList">
<ComboBoxEvents TValue="string" TItem="string" OnClose="@OnCloseHandler" />
</SfComboBox>
@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 dropdown popup opens.
Declaration
public EventCallback<BeforeOpenEventArgs> OnOpen { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<BeforeOpenEventArgs> | An Microsoft.AspNetCore.Components.EventCallback<> that receives a BeforeOpenEventArgs object when triggered. |
Remarks
This event is triggered before the dropdown popup opens, allowing cancellation of the open action via Cancel. It enables developers to perform pre-open logic or prevent the popup from opening.
Examples
<SfComboBox TItem="string" TValue="string" DataSource="@MyList">
<ComboBoxEvents TValue="string" TItem="string" OnOpen="@OnOpenHandler" />
</SfComboBox>
@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 dropdown popup.
Declaration
public EventCallback<SelectEventArgs<TItem>> OnValueSelect { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<SelectEventArgs<TItem>> | An Microsoft.AspNetCore.Components.EventCallback<> that receives a SelectEventArgs<T> object when triggered. |
Remarks
This event is triggered when an item is selected from the dropdown, providing details about the selected item via ItemData. It allows cancellation of the selection via Cancel.
Examples
<SfComboBox TValue="string" TItem="string" DataSource="@MyList">
<ComboBoxEvents TValue="string" TItem="string" OnValueSelect="@OnValueSelect" />
</SfComboBox>
@code {
protected List<string> MyList = new List<string> { "Apple", "Banana", "Orange" };
private void OnValueSelect(SelectEventArgs<string> args)
{
// Handle item selection
}
}
Opened
Gets or sets the event callback invoked after the dropdown popup is opened.
Declaration
public EventCallback<PopupEventArgs> Opened { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<PopupEventArgs> | An Microsoft.AspNetCore.Components.EventCallback<> that receives a PopupEventArgs object when triggered. |
Remarks
This event is triggered after the dropdown popup is opened, providing access to popup properties via Popup for further customization or interaction.
Examples
<SfComboBox TValue="string" TItem="string" DataSource="@MyList">
<ComboBoxEvents TValue="string" TItem="string" Opened="@OnOpened" />
</SfComboBox>
@code {
protected List<string> MyList = new List<string> { "Apple", "Banana", "Orange" };
private void OnOpened(PopupEventArgs args)
{
// Handle popup opened event
}
}
ValueChange
Gets or sets the event callback invoked when the Value property changes.
Declaration
public EventCallback<ChangeEventArgs<TValue, TItem>> ValueChange { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<ChangeEventArgs<TValue, TItem>> | An Microsoft.AspNetCore.Components.EventCallback<> that receives a ChangeEventArgs<TValue, TItem> object when triggered. |
Remarks
This event is triggered when an item is selected from the popup or when the user changes the model value, either by typing a custom value (if AllowCustom is enabled) or selecting an existing item. It provides access to the new and previous values for further processing.
Examples
<SfComboBox TItem="string" TValue="string" DataSource="@MyList">
<ComboBoxEvents TValue="string" TItem="string" ValueChange="@OnChange" />
</SfComboBox>
@code {
protected List<string> MyList = new List<string> { "Small", "Medium", "Large" };
public void OnChange(ChangeEventArgs<string, string> args)
{
var NewValue = args.Value;
}
}
Methods
ComponentDispose(Boolean)
Declaration
protected void ComponentDispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |