ReactFix
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • React
  • React Native
  • Programming
  • Object Oriented Programming

Monday, November 21, 2022

[FIXED] How to prevent drop on a particaular node in antD tree

 November 21, 2022     antd, javascript, reactjs   

Issue

Hi I am using antd tree for my React application. I am using drag and drop feature of the tree. I have this requirement where I should prevent user from dropping the dragged nodes on certain nodes. Is there any droppable='false' kind of config available on tree node to prevent the drop on the node?


Solution

allowDrop property should be a function, its parameter is node and its output is Boolean:({ dropNode, dropPosition }) => boolean this function execute for each node of your tree and base on output the node will be dropable or not

      allowDrop ={(node, dropPosition ) => {
        console.log(node, dropPosition );
        //add some funtionality
        return false; //return true/false base on funtionality
      }}


Answered By - Kamran Davar
Answer Checked By - - Mary Flores (ReactFix Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Newer Post Older Post Home

Featured Post

Is Learning React Difficult?

React is difficult to learn, no ifs and buts. React isn't inherently difficult to learn. It's a framework that's different from ...

Total Pageviews

Copyright © ReactFix