Search results

Dual list box

The dual list box allows the user to move items between two list boxes by clicking the toolbar buttons. Dual list box can be created by listing items in the ToolbarSettings along with the Scope property.

The following operations can be performed in dual list box,

Options Description
moveUp Move the selected item in the upward direction within the list box.
moveDown Move the selected item in the downward direction within the list box.
moveTo Move the selected item to the another list box.
moveFrom Move the selected item from one list box to the another list box.
moveAllTo Move all the items to the another list box.
moveAllFrom Move all the items from one list box to the another list box.

The following example illustrates how to move items from Group A to Group B list box.

@using Syncfusion.EJ2.Blazor.DropDowns

<div id="listbox1">
    <h4>Group A</h4>
    <EjsListBox TValue="string[]" DataSource="@GroupA" Scope="#listbox" Fields="@FieldSettings">
        <ListBoxToolbarSettings Items="@Items"></ListBoxToolbarSettings>
    </EjsListBox>
</div>
<div id="listbox2">
    <h4>Group B</h4>
    <EjsListBox TValue="string[]" ID="listbox" DataSource="@GroupB" Fields="@FieldSettings"></EjsListBox>
</div>

@code {
    public string[] Items = new string[] { "moveUp", "moveDown", "moveTo", "moveFrom", "moveAllTo", "moveAllFrom" };
    public List<CountryCode> GroupA = new List<CountryCode>
      {
        new CountryCode{ Name = "Australia", Code = "AU" },
        new CountryCode{ Name = "Bermuda", Code = "BM" },
        new CountryCode{ Name = "Canada", Code = "CA" },
        new CountryCode{ Name = "Cameroon", Code = "CM" },
        new CountryCode{ Name = "Denmark", Code = "DK" },
        new CountryCode{ Name = "France", Code = "FR" },
        new CountryCode{ Name = "Finland", Code = "FI" }
    };

    public List<CountryCode> GroupB = new List<CountryCode>
      {
        new CountryCode{ Name = "India", Code = "IN" },
        new CountryCode{ Name = "Italy", Code = "IT" },
        new CountryCode{ Name = "Japan", Code = "JP" },
        new CountryCode{ Name = "Mexico", Code = "MX" },
        new CountryCode{ Name = "Norway", Code = "NO" },
        new CountryCode{ Name = "Poland", Code = "PL" },
        new CountryCode{ Name = "Switzerland", Code = "CH" }
    };

    public class CountryCode {
        public string Name  { get; set; }
        public string Code  { get; set; }
    }

    public ListBoxFieldSettings FieldSettings = new ListBoxFieldSettings
    {
        Text = "Name"
    };
}

<style>
    #listbox1 {
        width: 48%;
        float: left;
    }

    #listbox2 {
        width: 48%;
        float: right;
    }
</style>

Output will be shown as

ListBox