creocoder / yii2-nested-sets

The nested sets behavior for the Yii framework.
Other
446 stars 129 forks source link

How to move nodes? #64

Open anton-p-ivanov opened 9 years ago

anton-p-ivanov commented 9 years ago

In Yii 1.x nested sets behavior there was methods for moving nodes inside tree, ex. moveAsLast(), moveAsFirst(). How to implement these methods in your Yii 2.x behavior?

creocoder commented 9 years ago

@anton-p-ivanov To move node use prependTo(), appendTo(), insertBefore() or insertAfter(). Will update documentation about that.

mikehaertl commented 9 years ago

@creocoder Why not add a convenience method for this which wraps up the necessary steps? Also, if you just call insertBefore() with an existing node, will it get removed from the old location automatically?

creocoder commented 9 years ago

@mikehaertl

Why not add a convenience method for this which wraps up the necessary steps?

Its already here.

if you just call insertBefore() with an existing node, will it get removed from the old location automatically?

Yes.

mikehaertl commented 9 years ago

I see now. Awesome! :+1:

set-st commented 9 years ago

при appendTo как то слетают lft и rgt у ноды родителя и depth у дочерней ноды. никто подобного не замечал больше? только у меня так?