Class DropDownListEvents<TValue, TItem>
Defines the events for the SfDropDownList<TValue, TItem> component.
Inheritance
Namespace: Syncfusion.Blazor.DropDowns
Assembly: Syncfusion.Blazor.dll
Syntax
public class DropDownListEvents<TValue, TItem> : OwningComponentBase
Type Parameters
Name | Description |
---|---|
TValue | The type of the value selected in the SfDropDownList<TValue, TItem>. |
TItem | The type of items displayed in the dropdown list. |
Remarks
This class provides event callbacks for various interactions with the SfDropDownList<TValue, TItem> component, such as data fetching, popup actions, and value changes.
Examples
<SfDropDownList TItem="string" TValue="string" DataSource="@MyList">
<DropDownListEvents TValue="string" TItem="string" ValueChange="@OnChange" OnOpen="@OnOpenHandler"/>
</SfDropDownList>
@code {
protected List<string> MyList = new List<string> { "Small", "Medium", "Large" };
public void OnChange(ChangeEventArgs<string, string> args)
{
// Handle value change
}
public void OnOpenHandler(BeforeOpenEventArgs args)
{
args.Cancel = true; // Prevent popup from opening
}
}
Constructors
DropDownListEvents()
Declaration
public DropDownListEvents()
Properties
BaseParent
Specifies the base parent of the component.
Declaration
protected SfDropDownList<TValue, TItem> BaseParent { get; set; }
Property Value
Type |
---|
SfDropDownList<TValue, TItem> |
Blur
Gets or sets the event callback invoked when the dropdown 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 SfDropDownList<TValue, TItem> component loses focus, allowing developers to perform actions such as UI updates or validation checks.
Examples
<SfDropDownList TItem="string" TValue="string" DataSource="@MyList">
<DropDownListEvents TValue="string" TItem="string" Blur="@OnBlurHandler"/>
</SfDropDownList>
@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 has 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
<SfDropDownList TItem="string" TValue="string" DataSource="@MyList">
<DropDownListEvents TValue="string" TItem="string" Closed="@OnClosedHandler"/>
</SfDropDownList>
@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 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 when the SfDropDownList<TValue, TItem> component is initialized and rendered, allowing developers to perform setup tasks or initialization logic.
Examples
<SfDropDownList TItem="string" TValue="string" DataSource="@MyList">
<DropDownListEvents TValue="string" TItem="string" Created="@OnCreatedHandler"/>
</SfDropDownList>
@code {
protected List<string> MyList = new List<string> { "Small", "Medium", "Large" };
public void OnCreatedHandler(object args)
{
Console.WriteLine("DropDownList created.");
}
}
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 dropdown popup, providing access to the populated items via Items. It is useful for post-processing or validating the data displayed in the popup.
Examples
<SfDropDownList TItem="string" TValue="string" DataSource="@MyList">
<DropDownListEvents TValue="string" TItem="string" DataBound="@OnDataBoundHandler"/>
</SfDropDownList>
@code {
protected List<string> MyList = new List<string> { "Small", "Medium", "Large" };
public void OnDataBoundHandler(DataBoundEventArgs args)
{
// Process populated data
}
}
Destroyed
Gets or sets the event callback invoked when the 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 receives an System.Object when triggered. |
Remarks
This event is triggered when the SfDropDownList<TValue, TItem> component is disposed, allowing developers to perform cleanup tasks or release resources.
Examples
<SfDropDownList TItem="string" TValue="string" DataSource="@MyList">
<DropDownListEvents TValue="string" TItem="string" Destroyed="@OnDestroyedHandler"/>
</SfDropDownList>
@code {
protected List<string> MyList = new List<string> { "Small", "Medium", "Large" };
public void OnDestroyedHandler(object args)
{
Console.WriteLine("DropDownList destroyed.");
}
}
Filtering
Gets or sets the event callback invoked when a character is typed in the filter textbox.
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 filter textbox and AllowFiltering is enabled. Developers can prevent the default filtering action using PreventDefaultAction and customize the filtering logic by passing a modified query to the FilterAsync
method.
Examples
<SfDropDownList @ref="DDLObj" TItem="string" TValue="string" AllowFiltering="true" DataSource="@MyList">
<DropDownListEvents TValue="string" TItem="string" Filtering="@OnFilteringHandler"/>
</SfDropDownList>
@code {
SfDropDownList<string, string> DDLObj { 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 DDLObj.FilterAsync(MyList, query);
}
}
Focus
Gets or sets the event callback invoked when the 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 receives an System.Object when triggered. |
Remarks
This event is triggered when the SfDropDownList<TValue, TItem> component gains focus, allowing developers to perform actions such as UI updates or input preparation.
Examples
<SfDropDownList TItem="string" TValue="string" DataSource="@MyList">
<DropDownListEvents TValue="string" TItem="string" Focus="@OnFocusHandler"/>
</SfDropDownList>
@code {
protected List<string> MyList = new List<string> { "Small", "Medium", "Large" };
public void OnFocusHandler(object args)
{
Console.WriteLine("DropDownList gained focus.");
}
}
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 triggered before the data fetch operation starts, allowing developers to modify the query or cancel the operation using Cancel. It is useful for initializing or customizing data retrieval logic.
Examples
<SfDropDownList TItem="string" TValue="string" DataSource="@MyList">
<DropDownListEvents TValue="string" TItem="string" OnActionBegin="@OnActionBeginHandler"/>
</SfDropDownList>
@code {
protected List<string> MyList = new List<string> { "Small", "Medium", "Large" };
public void OnActionBeginHandler(ActionBeginEventArgs args)
{
args.Cancel = true; // 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 Microsoft.AspNetCore.Components.EventCallback<> that receives an ActionCompleteEventArgs<TItem> object when triggered. |
Remarks
This event is triggered after the data fetch operation completes successfully, providing access to the fetched data via Result. Developers can use this event to process or modify the data before it is displayed in the dropdown.
Examples
<SfDropDownList TItem="string" TValue="string" DataSource="@MyList">
<DropDownListEvents TValue="string" TItem="string" OnActionComplete="@OnActionCompleteHandler"/>
</SfDropDownList>
@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 receives an System.Exception object when triggered. |
Remarks
This event is triggered when a data fetch operation fails, providing the exception details for error handling or logging purposes. Developers can use this event to display error messages or implement fallback logic.
Examples
<SfDropDownList TItem="string" TValue="string" DataSource="@MyList">
<DropDownListEvents TValue="string" TItem="string" OnActionFailure="@OnActionFailureHandler"/>
</SfDropDownList>
@code {
protected List<string> MyList = new List<string> { "Small", "Medium", "Large" };
public void OnActionFailureHandler(Exception ex)
{
Console.WriteLine($"Data fetch failed: {ex.Message}");
}
}
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 developers to cancel the action using Cancel. If cancelled, the popup remains open, enabling custom control over the closing behavior.
Examples
<SfDropDownList TItem="string" TValue="string" DataSource="@MyList">
<DropDownListEvents TValue="string" TItem="string" OnClose="@OnCloseHandler"/>
</SfDropDownList>
@code {
protected List<string> MyList = new List<string> { "Small", "Medium", "Large" };
public void OnCloseHandler(PopupEventArgs args)
{
args.Cancel = true; // Prevent popup from closing
}
}
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 developers to cancel the action using Cancel. It is useful for validating conditions or modifying the popup behavior before it is displayed.
Examples
<SfDropDownList TItem="string" TValue="string" DataSource="@MyList">
<DropDownListEvents TValue="string" TItem="string" OnOpen="@OnOpenHandler"/>
</SfDropDownList>
@code {
protected List<string> MyList = new List<string> { "Small", "Medium", "Large" };
public void OnOpenHandler(BeforeOpenEventArgs args)
{
args.Cancel = true; // Prevent popup from opening
}
}
OnResizeStart
Gets or sets the event callback invoked when the popup resizing action begins.
Declaration
public EventCallback<object> OnResizeStart { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<System.Object> | An Microsoft.AspNetCore.Components.EventCallback<> that receives an System.Object containing resize start data when triggered. |
Remarks
This event is triggered when the user starts resizing the dropdown popup, provided AllowResize is enabled. It is useful for initializing states, logging, or displaying messages during the resizing process.
Examples
<SfDropDownList TItem="string" TValue="string" AllowResize="true" DataSource="@MyList">
<DropDownListEvents TValue="string" TItem="string" OnResizeStart="@HandleResizeStart"/>
</SfDropDownList>
@code {
protected List<string> MyList = new List<string> { "Small", "Medium", "Large" };
public void HandleResizeStart(object args)
{
Console.WriteLine("Resizing has started.");
}
}
OnResizeStop
Gets or sets the event callback invoked when the popup resizing action is completed.
Declaration
public EventCallback<object> OnResizeStop { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<System.Object> | An Microsoft.AspNetCore.Components.EventCallback<> that receives an System.Object containing resize stop data when triggered. |
Remarks
This event is triggered when the user finishes resizing the dropdown popup, provided AllowResize is enabled. It is ideal for finalizing layout adjustments, saving the final size, or logging the resize completion.
Examples
<SfDropDownList TItem="string" TValue="string" AllowResize="true" DataSource="@MyList">
<DropDownListEvents TValue="string" TItem="string" OnResizeStop="@HandleResizeStop"/>
</SfDropDownList>
@code {
protected List<string> MyList = new List<string> { "Small", "Medium", "Large" };
public void HandleResizeStop(object args)
{
Console.WriteLine("Resizing has stopped.");
}
}
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 popup via mouse, tap, or keyboard navigation. Developers can prevent the selection using Cancel and access the selected item via ItemData.
Examples
<SfDropDownList TItem="string" TValue="string" DataSource="@MyList">
<DropDownListEvents TValue="string" TItem="string" OnValueSelect="@OnSelectHandler"/>
</SfDropDownList>
@code {
protected List<string> MyList = new List<string> { "Small", "Medium", "Large" };
public void OnSelectHandler(SelectEventArgs<string> args)
{
if (args.ItemData == "Medium")
args.Cancel = true; // Prevent selection
}
}
Opened
Gets or sets the event callback invoked when the dropdown popup opens.
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
<SfDropDownList TItem="string" TValue="string" DataSource="@MyList">
<DropDownListEvents TValue="string" TItem="string" Opened="@OnOpenedHandler"/>
</SfDropDownList>
@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 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 dropdown popup or when the value is changed programmatically. It provides details about the new and previous values, allowing developers to respond to value changes.
Examples
<SfDropDownList TItem="string" TValue="string" DataSource="@MyList">
<DropDownListEvents TValue="string" TItem="string" ValueChange="@OnChange"/>
</SfDropDownList>
@code {
protected List<string> MyList = new List<string> { "Small", "Medium", "Large" };
public void OnChange(ChangeEventArgs<string, string> args)
{
var selectedValue = args.Value;
}
}
Methods
ComponentDispose(Boolean)
Declaration
protected void ComponentDispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |