andkon / yii2dynatree
Tree widget for Yii2
Installs: 4 613
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
Language:JavaScript
Requires
- php: >=5.4.0
This package is not auto-updated.
Last update: 2025-01-10 21:59:17 UTC
README
docs: http://wwwendt.de/tech/dynatree/ demo: http://andkon.bl.ee/index.php?r=store install: php composer.phar require "andkon/yii2dynatree": "dev-master" Как использовать/How to use Model: need attributes: id - primary key parent_id - FK to id sort - INT order in tree name - STRING as label you can override the field names attribs $pkField $parentField $sortField Controller: class UnitController extends Controller { ... public function actions() { $actions = parent::actions(); $actions['moveintree'] = 'andkon\yii2dynatree\actions\MoveInTree'; // or $actions['moveintree'] = [ 'class' => andkon\yii2dynatree\actions\MoveInTree', 'sortField' => 'order', // override field name ]; return $actions; } ... } Widget: class Tree extends \andkon\yii2dynatree\Tree { public function init() { parent::init(); $this->functions['onClick'] = 'function (node, event) { unit.showDetal(node.data.key); }'; } } View: echo \app\pathToWidget\Tree::widget( [ 'id' => 'treeId', 'isAjax' => true, // true for use ajax load widget (in dialog|popup etc.) or false for standart render 'ajaxUrl' => Yii::$app->getUrlManager()->createUrl('/pathToController/moveintree'), 'model' => $model, ] );