The Tree widget based on Jquery-sortable-list,drag and drop to sort the tree.
The Sortable Tree widget based on Jquery-sortable-list,drag and drop to sort the tree., (*1)
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist xiongchuan/yii2-sortable-tree "*"
or add, (*4)
"xiongchuan/yii2-sortable-tree": "*"
to the require section of your composer.json., (*5)
Once the extension is installed, simply add widget to your page as follows:, (*6)
[ ['title' => 'Category 1'], ['title' => 'Category 2'], [ 'title' => 'Category 3', 'children' => [ [ 'title' => 'Category 3.1', ], [ 'title' => 'Category 3.2', 'children' => [ [ 'title' => 'Category 3.2.1', ] ], 'folder' => true, ], ], 'folder' => true, ], ], 'clientOptions' => [ 'autoCollapse' => true, 'clickFolderMode' => 3, 'activate' => new \yii\web\JsExpression(' function(node, data) { node = data.node; // Log node title console.log(node.title); } '), ], ]); ?>