This repository has been archived on 2024-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Wanderson Braganca d01ffd33f4 Fixed register script 2015-11-08 12:46:38 -02:00
src Fixed register script 2015-11-08 12:46:38 -02:00
.gitattributes Refactored code 2015-11-08 11:56:25 -02:00
.gitignore Refactored code 2015-11-08 11:56:25 -02:00
CHANGELOG.md Fixed register script 2015-11-08 12:46:38 -02:00
LICENSE initial commit 2014-06-04 16:56:14 -03:00
README.md initial commit 2014-06-04 16:56:14 -03:00
composer.json Update composer.json 2015-11-08 12:15:16 -02:00

README.md

yii2-fancytree-widget

The yii2-fancytree-widget is a Yii 2 wrapper for the Fancytree. A JavaScript dynamic tree view plugin for jQuery with support for persistence, keyboard, checkboxes, tables, drag'n'drop, and lazy loading.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist wbraganca/yii2-fancytree-widget "*"

or add

"wbraganca/yii2-fancytree-widget": "*"

to the require section of your composer.json file.

How to use

On your view file.


<?php
// 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']
	]]
];

echo \wbraganca\fancytree\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);
			}'),
		],
	]
]);
?>