dhtmlxTreeGrid moveRowTo() Infinite loop

Experiencing an infinite loop on moveRowTo() in version v2.1. I have a Treegrid where ‘A’ is the ultimate parent with a child of ‘B’. ‘B’ has a child of ‘C’.

A

-----B

   ----------C

I have a requirement where the user can click a button to make ‘C’ become the top of the tree. The result should look as:

C

-----A

   ----------B

I use moveRowTo() but the library goes into an infinite loop because I think it’s adding A to C before the delete happens. My code is as follows:

var selectedId = tree.getSelectedId();
tree.moveRowTo(tree.getRowId(0),selectedId,“move”,“child”,tree);

Is there a simple way to achieve a replacement of the top node in a treegrid without using a temporary treegrid?

Thank you.

Try to use

var selectedId = tree.getSelectedId(); tree.moveRowTo(selectedId,tree.getRowId(0),"move","sibling",tree); tree.moveRowTo(tree.getRowId(0),selectedId,"move","child",tree);

In such case it will remove item in question from childs of top item, as first step, and as second step reorder items as it necessary in your case

Thank you, works great although we have issues when there are a large number of nodes in the tree (i.e. greater than 700). Any suggestions for dealing with large structures when reorganizing in this way?

In case of treegrid , moving of branch will cause full re-rendering of all involved rows, which can cause performance issues if you are moving a big branch.
Unfortunately it can’t be seriously improved.