Drag and drop to box holder

I want to use the ListView component to drag and drop items into a div that will ask the user to drop items into as shown in attached file.  Once dropped I a method that will store the dragged item in a json list in local stoage.  

I have tried to find examples doing something similar but can't see any in the Syncfusion documentation.


Attachment: dragndrop_9594d67a.zip

3 Replies

KR Keerthana Rajendran Syncfusion Team September 30, 2021 08:56 AM UTC

Hi John,  

Thanks for contacting Syncfusion support. 

We checked your requirement to drag and drop items from ListView component. Currently ListView does not have drag and drop feature. However, you can utilize our Blazor ListBox component which is very similar to ListView and it has drag and drop support.   
  
Refer to the following links for more details on drag and drop with ListBox component.   
  
  
  
Please let us know if you need any further assistance. 

Regards, 
Keerthana R. 



JO John replied to Keerthana Rajendran September 30, 2021 09:05 AM UTC

Sorry, I should have tagged this as Listbox and not ListView.  The example you sent is what i've aready looked at.


Is there a way to style a list when there are no items in it?



AS Aravinthan Seetharaman Syncfusion Team October 1, 2021 12:53 PM UTC

 
We have checked your query. 
 
Query: Regarding Drag listbox items to Empty container. 
 
Ans: We have checked this query. We can able to achieve this requirement by using Drag and Drop support between two Listboxes. Please refer the below code snippet and sample. 
 
 
 
<div id="listbox1"> 
    <h4>Group A</h4> 
    <SfListBox TValue="string[]" DataSource="@GroupA" AllowDragAndDrop="true" Scope="combined-list" Height="290px" TItem="CountryCode"> 
        <ListBoxFieldSettings Text="Name" Value="Code" /> 
    </SfListBox> 
</div> 
<div id="listbox2"> 
    <h4>Group B</h4> 
    <SfListBox TValue="string[]" DataSource="@GroupB" Scope="combined-list" AllowDragAndDrop="true" Height="290px" TItem="CountryCode" @ref="list2Obj"> 
        <ListBoxFieldSettings Text="Name" Value="Code" /> 
    </SfListBox> 
</div> 
<SfButton OnClick="getData">Get Updated Data</SfButton> 
@code { 
    SfListBox<string[], CountryCode> list2Obj; 
    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" }, 
        new CountryCode{ Name = "Germany", Code = "DE" }, 
        new CountryCode{ Name = "Hong Kong", Code = "HK" } 
    }; 
 
    public List<CountryCode> GroupB = new List<CountryCode> 
    { 
 
    }; 
 
    public class CountryCode 
    { 
        public string Name { get; set; } 
        public string Code { get; set; } 
    } 
    public void getData() 
    { 
        var data=this.list2Obj.GetDataList(); 
    } 
 
} 
 
  
 
For more details, please refer the below UG link. 
 
 
 
Query: Is there a way to style a list when there are no items in it? 
 
Ans: We can able to customize by overriding css in Listbox. Please refer the below code snippet. 
 
   #listbox2 .e-listbox-container { 
     background-color: aliceblue; 
    } 
 
For more details, regarding appearance of Listbox please refer the below UG link. 
 
 
Could you please check the above details and get back to us, if you need assistance on this. 
 
Regards, 
Aravinthan S



Loader.
Up arrow icon