All Projects → DevGroup-ru → yii2-jstree-widget

DevGroup-ru / yii2-jstree-widget

Licence: MIT license
jsTree tree widget for yii2

Programming Languages

PHP
23972 projects - #3 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to yii2-jstree-widget

yii2-grid-view-library
Highly enhanced GridView widget and grid components for Yii2
Stars: ✭ 57 (+256.25%)
Mutual labels:  widget, yii
nested-set
Nested Set is an Go implementation of the Nested set model for Gorm.
Stars: ✭ 44 (+175%)
Mutual labels:  tree, nested-set
yii2-selectize-widget
Selectize From Brian Reavis Yii2 Widget
Stars: ✭ 73 (+356.25%)
Mutual labels:  widget, yii
yii2-multi-select-widget
Bootstrap MultiSelect and MultiSelect Listbox widgets for Yii2
Stars: ✭ 45 (+181.25%)
Mutual labels:  widget, yii
Django Jsoneditor
Django JSONEditor input widget to provide javascript online JSON Editor
Stars: ✭ 124 (+675%)
Mutual labels:  tree, widget
Yii2 Ckeditor Widget
CKEditor WYSIWYG widget for Yii2.
Stars: ✭ 163 (+918.75%)
Mutual labels:  widget, yii
yii2-editable-widget
X-Editable Widget for Yii2
Stars: ✭ 56 (+250%)
Mutual labels:  widget, yii
Graphview
Flutter GraphView is used to display data in graph structures. It can display Tree layout, Directed and Layered graph. Useful for Family Tree, Hierarchy View.
Stars: ✭ 152 (+850%)
Mutual labels:  tree, widget
stefano-tree
Framework agnostic Nested Set (MPTT) implementation for PHP
Stars: ✭ 24 (+50%)
Mutual labels:  tree, nested-set
Graph-Theory
The Repository is All about the Graph Algorithms. I am Still Working On it. I am trying to Note down all the variations of Popular graph Algorithms. I am also keeping the solution to the problems of Different Online Judges according to the topic. I hope you can find it useful.
Stars: ✭ 16 (+0%)
Mutual labels:  tree
extraction
Tree Extraction for JavaScript Object Graphs
Stars: ✭ 70 (+337.5%)
Mutual labels:  tree
stagtools
StagTools is a powerful plugin to extend functionality to your WordPress themes offering shortcodes, FontAwesome icons, and useful widgets.
Stars: ✭ 21 (+31.25%)
Mutual labels:  widget
Pagination
a paging widget based on Qt
Stars: ✭ 22 (+37.5%)
Mutual labels:  widget
Accordion
Silky-smooth accordion widgets with no external dependencies.
Stars: ✭ 32 (+100%)
Mutual labels:  widget
ofxSpaceColonization
Space Colonization algorithm implementation in openFrameworks
Stars: ✭ 62 (+287.5%)
Mutual labels:  tree
flutter plugins
Flutter插件集合,好用常用的插件.
Stars: ✭ 22 (+37.5%)
Mutual labels:  widget
tree-vue
A lightweight library for handling hierarchical content. With full customizations of items rendering.
Stars: ✭ 25 (+56.25%)
Mutual labels:  tree
handy-scroll
Handy dependency-free floating scrollbar widget
Stars: ✭ 15 (-6.25%)
Mutual labels:  widget
Crypti
A minimal bitcoin price desktop widget
Stars: ✭ 33 (+106.25%)
Mutual labels:  widget
cp-react-tree-table
A fast, efficient tree table component for ReactJS.
Stars: ✭ 83 (+418.75%)
Mutual labels:  tree

yii2-jstree-widget

Code Climate SensioLabsInsight Scrutinizer Code Quality Build Status

jsTree tree widget for yii2.

Current state: unstable.

Description

This extension allows you to display and manage hierarchical data structures from your database using jsTree.

For now following data structure types are supported:

Usage example

For example, we have model Menu that represents our structured data. And MenuController for management purposes.

Adjacency List

In the MenuController:

use devgroup\JsTreeWidget\actions\AdjacencyList\FullTreeDataAction;
use devgroup\JsTreeWidget\actions\AdjacencyList\TreeNodesReorderAction;
use devgroup\JsTreeWidget\actions\AdjacencyList\TreeNodeMoveAction;
...
public function actions()
    {
        return [
            'getTree' => [
                'class' => FullTreeDataAction::class,
                'className' => Menu::class,
            ],
            'menuReorder' => [
                'class' => TreeNodesReorderAction::class,
                'className' => Menu::class,
            ],
            'menuChangeParent' => [
                'class' => TreeNodeMoveAction::class,
                'className' => Menu::class,
            ],
        ];
    }

In your view file call the widget in the right place:

    <?= TreeWidget::widget([
            'treeDataRoute' => ['/menu/getTree', 'selected_id' => $parent_id],
            'reorderAction' => ['/menu/menuReorder'],
            'changeParentAction' => ['/menu/menuChangeParent'],
            'treeType' => TreeWidget::TREE_TYPE_ADJACENCY,
            'contextMenuItems' => [
                'open' => [
                    'label' => 'Open',
                    'action' => ContextMenuHelper::actionUrl(
                        ['/menu/list'],
                        ['parent_id']
                    ),
                ],
                'edit' => [
                    'label' => 'Edit',
                    'action' => ContextMenuHelper::actionUrl(
                        ['/menu/edit']
                    ),
                ]
            ],
        ]) ?>

Getting Data, Reordering and Change Parent actions has default implementations, but you can implement and use your own ones, just by changing a routes 'treeDataRoute', 'reorderAction', 'changeParentAction'.

Nested Set

Nested set can work in single or multy root modes. Single root mode by default. For using multi root mode you have to have tree (or other name you like) column in your database table to store root id. And define this name in all necessary config places (see below).

In the MenuController:

use devgroup\JsTreeWidget\actions\nestedset\FullTreeDataAction;
use devgroup\JsTreeWidget\actions\nestedset\NodeMoveAction;
...
public function actions()
    {
        return [
            'getTree' => [
                'class' => FullTreeDataAction::class,
                'className' => Menu::class,
                'rootAttribute' => 'tree', //omit for single root mode
            ],
            'treeReorder' => [
                'class' => NodeMoveAction::class,
                'className' => Menu::class,
                'rootAttribute' => 'tree', //omit for single root mode
            ],
        ];
    }

In the view file:

    <?= TreeWidget::widget([
        'treeDataRoute' => ['/menu/getTree'],
        'reorderAction' => ['/menu/treeReorder'],
        'treeType' => TreeWidget::TREE_TYPE_NESTED_SET, //important config option
        'contextMenuItems' => [
            'edit' => [
                'label' => 'Edit',
                'action' => ContextMenuHelper::actionUrl(
                    ['/menu/edit']
                ),
            ]
        ],
    ]) ?>

Getting Data and Node Movements actions has the default implementations and are independent from side NestedSet behaviors. But you also can use your own implementation.

TreeWidget will register bundle JsTreeAssetBundle, but you may want to include it as dependency in your main bundle(ie. for minification purpose).

ContextMenuHelper creates JsExpression for handling context menu option click. It automatically adds all data attributes from item link(<a> tag) if it is not specified exactly(as in 'open' menu item).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].