DragDrop Order (or Via Buttons)

I am looking at this demo:

https://blazor.syncfusion.com/demos/listbox/drag-and-drop

This appears to have the functionality/behavior that I would like to achieve, but when using one Listbox (and not two), I cannot seem to make this work.  Is there a demo somewhere that demonstrates how to achieve drag/drop order with one ListBox?

I am also interested in being able to reorder list items via up/down buttons.

Thank you for any guidance/suggestions you can provide.


3 Replies 1 reply marked as answer

YA YuvanShankar Arunagiri Syncfusion Team May 9, 2022 05:07 AM UTC

Hi Mike,


We have prepared a sample code based on your requirement. Please refer the below code snippet.


[Index.Razor]


@using Syncfusion.Blazor.DropDowns

 

<div class="dual-list-groupa">

    <SfListBox Scope="@scope1" DataSource="@groupA" TItem="ListItem" Height="330px" AllowDragAndDrop="true" TValue="string[]" @attributes="listbox1Attr">

        <ListBoxFieldSettings Text="Name" Value="Code"></ListBoxFieldSettings>

        <ListBoxToolbarSettings Items="@items"></ListBoxToolbarSettings>

    </SfListBox>

</div>

 

 

@code

{

    private string[] items = new string[] { "MoveUp", "MoveDown" };

    private readonly string scope1 = "scope1";

    private readonly Dictionary<string, object> listbox1Attr = new Dictionary<string, object>

    {

        { "id", "scope1" }

    };

    private List<ListItem> groupA = new List<ListItem> {

        new ListItem { Name = "Australia", Code = "AU" },

        new ListItem { Name = "Bermuda", Code = "BM" },

        new ListItem { Name = "Canada", Code = "CA" },

        new ListItem { Name = "Cameroon", Code = "CM" },

        new ListItem { Name = "Denmark", Code = "DK" }

    };

    public class ListItem

    {

        public string Name { get; set; }

        public string Code { get; set; }

    }

}


Could you please check with above code and get back to us, if you need any further assistance on this. 


Regards,

YuvanShankar A


Marked as answer

MI Mike-E May 9, 2022 11:06 AM UTC

Excellently perfect @YuvanShankar!  Thank you very much for taking the time to put that together and for highlighting the pertinent pieces.  Worked the first time for me. :)


I appreciate you and all your team members out there doing all such great work. 🙏



YA YuvanShankar Arunagiri Syncfusion Team May 10, 2022 04:14 AM UTC

Hi Mike,


We are happy to hear that your requirement has been fulfilled. Please get back to us if you need any further assistance on this.


Regards,

YuvanShankar A


Loader.
Up arrow icon