NodeDropped not cancel event


Hi,

Why does the code below not cancel the event?

  <SfTreeView TValue="peopleTable" CssClass="custom" @ref="tree" AllowDragAndDrop="true">
       <TreeViewEvents TValue="peopleTable"  NodeSelected="OnSelect" NodeDropped="OnDroped" OnNodeDragStart="OnNodeDragStartX" ></TreeViewEvents>
   </SfTreeView>                                
   

 public async void OnDroped(DragAndDropEventArgs args)
    {

        if(condidion==true)
       {
           args.Cancel = true;
       }

}

Tks.

3 Replies 1 reply marked as answer

MK Muthukrishnan Kandasamy Syncfusion Team April 20, 2021 10:17 AM UTC

 
Hi Marcelo, 
 
Thanks for contacting Syncfusion support. 
 
We have validated your reported problem in Syncfusion Blazor TreeView component. We would like to let you know that NodeDropped event triggers after the node was completely dropped on the target. Currently, we haven’t provided support to cancel this action. For achieving your requirement, we suggest you to use the OnNodeDragStop event. By using this event, we can prevent the node drop action. Please refer to the below code block. 
 
<SfTreeView TValue="TeamDetails" AllowDragAndDrop="true"> 
    <TreeViewEvents TValue="TeamDetails" OnNodeDragStop="NodeDragStop"></TreeViewEvents> 
    <TreeViewFieldsSettings TValue="TeamDetails" Id="Id" Text="Name" Child="Children" DataSource="@Team" Expanded="Expanded"></TreeViewFieldsSettings> 
</SfTreeView>  
 
@code{ 
 
    bool condition = true; 
    public async void NodeDragStop(DragAndDropEventArgs args) 
    { 
        if (condition == true) 
        { 
            args.Cancel = true; 
        } 
    } 
 
We have also prepared sample application to meet your requirement, which can be downloaded from the below link. 
 
 
Please refer to the below links to know more about TreeView component. 
 
 
 
 
Please confirm whether the provided solution is met your requirement or do you expecting this support need to be included in NodeDropped event ? 
 
Regards, 
Muthukrishnan K 


Marked as answer

MO Marcelo Oliveira Santos April 20, 2021 09:31 PM UTC

Hi Muthukrishnan K ,

Thank you for your quick reply. The information was useful, most to me.


SP Sowmiya Padmanaban Syncfusion Team April 21, 2021 04:41 AM UTC

Hi Marcelo,  
  
Most Welcome. We are happy to hear that your problem has been resolved. Please contact us, if you need any help from us. 
  
Regards,  
Sowmiya.P 


Loader.
Up arrow icon