Drag and Drop target

Good Day,

i got a little problem in my project. I want to save changed data in my database after a item was dropped in another ListBox.
I was able to get the events right (I think so at least). But now I encountered the problem that I'm not able to get the information on what my target is.

I have a list, where I display all my tasks. Those tasks I want to drag into one of my projects (which are displayed in cards). The problem is, that I can't figure out, how to get my project/id.

Kind regards,
Jan

1 Reply 1 reply marked as answer

AS Aravinthan Seetharaman Syncfusion Team May 19, 2021 01:52 AM UTC

 
Thanks for contacting Syncfusion Support. 
 
We have checked your query. We can achieve your requirement by using Dropped event in ListBox. Please refer the below code snippet and sample. 
 
 
<SfListBox DataSource="@groupA" Scope="@scope" TItem="ListItem" AllowDragAndDrop="true" Height="330px" TValue="string[]" @ref="ListObj1"> 
                <ListBoxFieldSettings Text="Name" Value="Code"></ListBoxFieldSettings> 
                <ListBoxEvents TItem="ListItem" TValue="string[]" Dropped="OnDrop"></ListBoxEvents> 
            </SfListBox> 
        </div> 
        <span class="e-swap-icon"></span> 
        <div class="listbox-control"> 
            <h4>Group B</h4> 
            <SfListBox DataSource="@groupB" Scope="@scope" TItem="ListItem" AllowDragAndDrop="true" Height="330px" TValue="string[]" @ref="ListObj2"> 
                <ListBoxFieldSettings Text="Name" Value="Code"></ListBoxFieldSettings> 
                <ListBoxEvents TItem="ListItem" TValue="string[]" Dropped="OnDrop"></ListBoxEvents> 
            </SfListBox> 
 
 
public void OnDrop(DragEventArgs<ListItem> args) 
    { 
        IEnumerable<ListItem> List1= ListObj1.GetDataList(); 
            foreach(var item in args.Items) 
            { 
                if (List1.Contains(item) == true) 
                { 
                    target = "ListBox1"; 
                } 
                else 
                { 
                    target = "ListBox2"; 
                } 
            } 
    } 
 
 
If we misunderstood your requirement, please share more details. So that we can work on this and provide you a better solution quickly. 
 
Regards, 
Aravinthan S 


Marked as answer
Loader.
Up arrow icon