Blazor

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

    Show / Hide Table of Contents

    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.

    Inheritance
    System.Object
    SfBaseComponent
    SfDataBoundComponent
    SfDropDownBase<TItem>
    SfListBox<TValue, TItem>
    Inherited Members
    Syncfusion.Blazor.DropDowns.SfDropDownBase<TItem>.Render(System.Collections.Generic.IEnumerable<TItem>, Syncfusion.Blazor.DropDowns.FieldSettingsModel, Syncfusion.Blazor.Data.Query)
    Syncfusion.Blazor.DropDowns.SfDropDownBase<TItem>.SetListData(System.Collections.Generic.IEnumerable<TItem>, Syncfusion.Blazor.DropDowns.FieldSettingsModel, Syncfusion.Blazor.Data.Query)
    SfDropDownBase<TItem>.SetFields()
    SfDropDownBase<TItem>.SimpleDataExecute(IEnumerable<TItem>, Query)
    SfDropDownBase<TItem>.CloneQuery(Query)
    Syncfusion.Blazor.DropDowns.SfDropDownBase<TItem>.GetDataByText(System.String, System.String)
    Syncfusion.Blazor.DropDowns.SfDropDownBase<TItem>.IncrementalSearch(System.String, System.Collections.Generic.IEnumerable<TItem>, System.Nullable<System.Int32>, System.Boolean)
    Syncfusion.Blazor.DropDowns.SfDropDownBase<TItem>.Search(System.String, System.Collections.Generic.IEnumerable<TItem>, System.String, System.Boolean)
    SfDropDownBase<TItem>.SetItemValue(String, Type)
    SfDropDownBase<TItem>.IsSimpleDataType()
    Syncfusion.Blazor.DropDowns.SfDropDownBase<TItem>.AddItems(System.Collections.Generic.IEnumerable<TItem>, System.Nullable<System.Int32>)
    SfDropDownBase<TItem>.AddItemsAsync(IEnumerable<TItem>, Nullable<Int32>)
    SfDropDownBase<TItem>.InsertItem(IEnumerable<TItem>, Nullable<Int32>, Boolean)
    Syncfusion.Blazor.DropDowns.SfDropDownBase<TItem>.RenderItems()
    Syncfusion.Blazor.DropDowns.SfDropDownBase<TItem>.HighlightSearch(System.String, System.String, System.Boolean, Syncfusion.Blazor.DropDowns.FilterType)
    SfDropDownBase<TItem>.ListItemCreated(ListOptions<TItem>)
    SfDropDownBase<TItem>.EnablePersistence
    SfDropDownBase<TItem>.ItemTemplate
    SfDropDownBase<TItem>.GroupTemplate
    SfDropDownBase<TItem>.NoRecordsTemplate
    SfDropDownBase<TItem>.ActionFailureTemplate
    SfDropDownBase<TItem>.SortOrder
    SfDropDownBase<TItem>.Enabled
    SfDropDownBase<TItem>.DataSource
    SfDropDownBase<TItem>.Query
    SfDropDownBase<TItem>.DuplicateQuery
    SfDropDownBase<TItem>.FilterType
    SfDropDownBase<TItem>.IgnoreCase
    SfDropDownBase<TItem>.IgnoreAccent
    SfDropDownBase<TItem>.ZIndex
    SfDropDownBase<TItem>.DropDownsEditContext
    Syncfusion.Blazor.DropDowns.SfDropDownBase<TItem>.ListData
    Syncfusion.Blazor.DropDowns.SfDropDownBase<TItem>.MainData
    Syncfusion.Blazor.DropDowns.SfDropDownBase<TItem>.ListDataSource
    Syncfusion.Blazor.DropDowns.SfDropDownBase<TItem>.DataId
    Syncfusion.Blazor.DropDowns.SfDropDownBase<TItem>.ItemData
    Syncfusion.Blazor.DropDowns.SfDropDownBase<TItem>.IsActionFaiure
    Syncfusion.Blazor.DropDowns.SfDropDownBase<TItem>.TotalCount
    SfDataBoundComponent.SetDataManager<T>(Object)
    SfDataBoundComponent.DataManager
    SfDataBoundComponent.MainParent
    SfBaseComponent.Dispose()
    SfBaseComponent.Dispose(Boolean)
    SfBaseComponent.OnObservableChange(String, Object, Boolean, NotifyCollectionChangedEventArgs)
    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

    true, if the drag and drop is performed in the listbox. The default value is true.

    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

    true, if the filtering is performed in the listbox. The default value is true.

    ComponentName

    Declaration
    protected override string ComponentName { get; set; }
    Property Value
    Type Description
    System.String
    Overrides
    Syncfusion.Blazor.DropDowns.SfDropDownBase<TItem>.ComponentName

    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 String.Empty.

    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

    true, if the right to left direction is enabled for listbox. The default value is false.

    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 500.

    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
    Syncfusion.Blazor.DropDowns.SfDropDownBase<TItem>.ActionBegin(System.Collections.Generic.IEnumerable<TItem>, Syncfusion.Blazor.Data.Query)

    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
    Syncfusion.Blazor.DropDowns.SfDropDownBase<TItem>.ActionComplete(System.Collections.Generic.IEnumerable<TItem>, Syncfusion.Blazor.Data.Query)

    ActionFailure(Object)

    Declaration
    protected override Task ActionFailure(object args)
    Parameters
    Type Name Description
    System.Object args
    Returns
    Type Description
    System.Threading.Tasks.Task
    Overrides
    Syncfusion.Blazor.DropDowns.SfDropDownBase<TItem>.ActionFailure(System.Object)

    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
    Syncfusion.Blazor.DropDowns.SfDropDownBase<TItem>.GetQuery(Syncfusion.Blazor.Data.Query)

    IsFilter()

    Declaration
    protected override bool IsFilter()
    Returns
    Type Description
    System.Boolean
    Overrides
    Syncfusion.Blazor.DropDowns.SfDropDownBase<TItem>.IsFilter()

    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
    SfDataBoundComponent.OnAfterRenderAsync(Boolean)

    OnInitializedAsync()

    Declaration
    protected override Task OnInitializedAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task
    Overrides
    Syncfusion.Blazor.DropDowns.SfDropDownBase<TItem>.OnInitializedAsync()

    OnParametersSetAsync()

    Declaration
    protected override Task OnParametersSetAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task
    Overrides
    Syncfusion.Blazor.DropDowns.SfDropDownBase<TItem>.OnParametersSetAsync()

    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 true/false to select/ unselect the entire list items.

    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
    Back to top Generated by DocFX
    Copyright © 2001 - 2022 Syncfusion Inc. All Rights Reserved