Usage
Demo
Source
<?php
use yii\web\JsExpression;
use wbraganca\fancytree\FancytreeWidget;
// Example of data.
$data = [
['title' => 'Node 1', 'key' => 1],
['title' => 'Folder 2', 'key' => '2', 'folder' => true, 'children' => [
['title' => 'Node 2.1', 'key' => '3'],
['title' => 'Node 2.2', 'key' => '4']
]]
];
?>
<?= FancytreeWidget::widget([
'options' =>[
'source' => $data,
'extensions' => ['dnd'],
'dnd' => [
'preventVoidMoves' => true,
'preventRecursiveMoves' => true,
'autoExpandMS' => 400,
'dragStart' => new JsExpression('function(node, data) {
return true;
}'),
'dragEnter' => new JsExpression('function(node, data) {
return true;
}'),
'dragDrop' => new JsExpression('function(node, data) {
data.otherNode.moveTo(node, data.hitMode);
}'),
],
]
]) ?>