Class SfListBox<TValue, TItem>
ListBox component used to display a list of items. Users can select one or more items in the list using a checkbox or by keyboard selection. It supports sorting, grouping, reordering and drag and drop of items.
Inherited Members
Namespace: Syncfusion.Blazor.DropDowns
Assembly: Syncfusion.Blazor.dll
Syntax
public class SfListBox<TValue, TItem> : SfDropDownBase<TItem>, IListBox
Type Parameters
Name | Description |
---|---|
TValue | |
TItem |
Examples
In the below code example, showcases a basic listbox.
<SfListBox Value=@value DataSource="@vehicleData" TValue="string[]" TItem="ListItem">
<ListBoxFieldSettings Text="Text" Value="Id"></ListBoxFieldSettings>
</SfListBox>
@code{
privatestring[] value= newstring[] { "List-01"};
privateList<ListItem>vehicleData = newList<ListItem>{
newListItem { Text = "Hennessey Venom", Id = "List-01"},
newListItem { Text = "Bugatti Chiron", Id = "List-02"},
newListItem { Text = "Bugatti Veyron Super Sport", Id = "List-03"}
}
}
In the below code example, showcases a basic ListBox component.
<SfListBox Value=@valueDataSource="@vehicleData" TValue="string[]" TItem="ListItem">
<ListBoxFieldSettings Text="Text" Value="Id"></ListBoxFieldSettings>
</SfListBox>
@code{
privatestring[] value= newstring[] { "List-01"};
privateList<ListItem>vehicleData = newList<ListItem>{
newListItem { Text = "Hennessey Venom", Id = "List-01"},
newListItem { Text = "Bugatti Chiron", Id = "List-02"},
newListItem { Text = "Bugatti Veyron Super Sport", Id = "List-03"}
}
}
Constructors
SfListBox()
Declaration
public SfListBox()
Properties
AllowDragAndDrop
Gets or sets a value that indicates whether to enable or disable the drag and drop support in the listbox.
Declaration
public bool AllowDragAndDrop { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
ListBox contains same 'Scope' property to perform drag and drop between multiple list boxes.
AllowFiltering
Gets or sets a value that indicates whether to enable or diaable the filtering in the listbox.
Declaration
public bool AllowFiltering { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
ComponentName
Declaration
protected override string ComponentName { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Overrides
CssClass
Gets or sets a value that indicates CSS class string to customize the appearance of listbox.
Declaration
public string CssClass { get; set; }
Property Value
Type | Description |
---|---|
System.String | Accepts a CSS class string separated by space to customize the appearance of listbox. The default value is |
EnableRtl
Gets or sets a value that indicates whether to enable or disable the right to left direction in listbox.
Declaration
public bool EnableRtl { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
FilterBarPlaceholder
Gets or sets a value that indicates the watermark text on the filter bar.
Declaration
public string FilterBarPlaceholder { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Height
Gets or sets a value that indicates the height of the listbox.
Declaration
public string Height { get; set; }
Property Value
Type | Description |
---|---|
System.String |
HtmlAttributes
Gets or sets a collection of additional attributes that will applied to the listbox container element.
Declaration
public Dictionary<string, object> HtmlAttributes { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.String, System.Object> |
Remarks
Additional attributes can be added by specifying as inline attributes or by specifying @attributes
directive.
MaximumSelectionLength
Gets or sets a value that indicates the limitation to the value selection in the listbox.
Declaration
public double MaximumSelectionLength { get; set; }
Property Value
Type | Description |
---|---|
System.Double | Accepts a double value. The default value is |
Remarks
Based on the limitation, list selection will be prevented.
Scope
Gets or sets a value that indicates the scope to the listbox to perform drag and drop and toolbar action.
Declaration
public string Scope { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Value
Gets or sets a value that indicates the specified item in the selected state of the listbox.
Declaration
public TValue Value { get; set; }
Property Value
Type | Description |
---|---|
TValue |
ValueChanged
Gets or sets the event callback to trigger when the value changes.
Declaration
public EventCallback<TValue> ValueChanged { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<TValue> |
ValueExpression
Gets or sets a value that indicates the expression for defining the value of the bound.
Declaration
public Expression<Func<TValue>> ValueExpression { get; set; }
Property Value
Type | Description |
---|---|
System.Linq.Expressions.Expression<System.Func<TValue>> |
Methods
ActionBegin(IEnumerable<TItem>, Query)
Declaration
protected override Task<ActionBeginEventArgs> ActionBegin(IEnumerable<TItem> dataSource, Query query = null)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<TItem> | dataSource | |
Query | query |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ActionBeginEventArgs> |
Overrides
ActionComplete(IEnumerable<TItem>, Query)
Declaration
protected override Task ActionComplete(IEnumerable<TItem> dataSource, Query query = null)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<TItem> | dataSource | |
Query | query |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Overrides
ActionFailure(Object)
Declaration
protected override Task ActionFailure(object args)
Parameters
Type | Name | Description |
---|---|---|
System.Object | args |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Overrides
BuildRenderTree(RenderTreeBuilder)
Declaration
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder | __builder |
EnableItems<T>(T, Boolean)
Enables or disables the items in the listbox based on the items and enable argument.
Declaration
public void EnableItems<T>(T items, bool enable = true)
Parameters
Type | Name | Description |
---|---|---|
T | items | Specifies the list items to be enabled or disabled. You can pass either value(TValue) or data source(TItem) collection. |
System.Boolean | enable | Set false to disable the items. By default the items will be enabled. |
Type Parameters
Name | Description |
---|---|
T |
GetDataByValue(TValue)
Gets the list of data object that matches the given list of values.
Declaration
public List<TItem> GetDataByValue(TValue dataValue)
Parameters
Type | Name | Description |
---|---|---|
TValue | dataValue | Specifies the value(s). |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<TItem> | The list of data object. |
GetDataList()
Gets the updated dataSource in ListBox.
Declaration
public IEnumerable<TItem> GetDataList()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<TItem> | The list of data object. |
GetPersistData()
Declaration
protected Task<string> GetPersistData()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.String> |
GetQuery(Query)
Declaration
protected override Query GetQuery(Query query)
Parameters
Type | Name | Description |
---|---|---|
Query | query |
Returns
Type | Description |
---|---|
Query |
Overrides
IsFilter()
Declaration
protected override bool IsFilter()
Returns
Type | Description |
---|---|
System.Boolean |
Overrides
MoveAllAsync(String, Nullable<Double>)
Moves all the values from one ListBox to the scoped ListBox.
Declaration
public Task MoveAllAsync(string scope = null, Nullable<double> index = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | scope | Specifies the destination ListBox reference. |
System.Nullable<System.Double> | index | Specifies the index to place the moved items. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
MoveAsync(TValue, Nullable<Double>, String)
Moves the given value(s) / selected value(s) to the given / default scoped ListBox.
Declaration
public Task MoveAsync(TValue values = null, Nullable<double> index = null, string scope = null)
Parameters
Type | Name | Description |
---|---|---|
TValue | values | Specifies the value(s). |
System.Nullable<System.Double> | index | Specifies the index to place the moved items. |
System.String | scope | Specifies the destination ListBox reference. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
MoveDownAsync(TValue)
Moves the given value(s) / selected value(s) downwards.
Declaration
public Task MoveDownAsync(TValue values = null)
Parameters
Type | Name | Description |
---|---|---|
TValue | values | Specifies the value(s). |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
MoveUpAsync(TValue)
Moves the given value(s) / selected value(s) upwards.
Declaration
public Task MoveUpAsync(TValue values = null)
Parameters
Type | Name | Description |
---|---|---|
TValue | values | Specifies the value(s). |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
OnAfterRenderAsync(Boolean)
Declaration
protected override Task OnAfterRenderAsync(bool firstRender)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | firstRender |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Overrides
OnInitializedAsync()
Declaration
protected override Task OnInitializedAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Overrides
OnParametersSetAsync()
Declaration
protected override Task OnParametersSetAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Overrides
RemoveItemAsync(IEnumerable<TItem>, Nullable<Int32>)
Removes a item or collection of items from the list. By default, removed the last item in the list, but you can remove based on the index parameter.
Declaration
public Task RemoveItemAsync(IEnumerable<TItem> items = null, Nullable<int> itemIndex = null)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<TItem> | items | Specifies the list of data collection to be removed. |
System.Nullable<System.Int32> | itemIndex | Specifies the index to remove the item from the list. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A Task that completes when the removing items. |
SelectAllAsync(Boolean)
Selects or deselects the entire listbox items based on the state parameter.
Declaration
public Task SelectAllAsync(bool state = true)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | state | Set |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
SelectItemsAsync<T>(T, Boolean)
Selects or deselects the sepecific listbox items based on the state parameter.
Declaration
public Task SelectItemsAsync<T>(T items, bool state = true)
Parameters
Type | Name | Description |
---|---|---|
T | items | Specifies the list items to be selected or unselected. You can pass either value(TValue) or data source(TItem) collection. |
System.Boolean | state | Set false to un select the items. By default the items will be selected. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Type Parameters
Name | Description |
---|---|
T |
SetLocalStorage(String, List<String>)
Declaration
protected Task SetLocalStorage(string persistId, List<string> values)
Parameters
Type | Name | Description |
---|---|---|
System.String | persistId | |
System.Collections.Generic.List<System.String> | values |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |