2017 © Pedro Peláez
 

yii2-extension yii2-widget-bootstraptreeview

Bootstrap Tree View widget wrapper for yii2

image

execut/yii2-widget-bootstraptreeview

Bootstrap Tree View widget wrapper for yii2

  • Monday, April 2, 2018
  • by eXeCUT
  • Repository
  • 4 Watchers
  • 36 Stars
  • 25,330 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 16 Forks
  • 1 Open issues
  • 5 Versions
  • 8 % Grown

The README.md

Bootstrap Tree View widget wrapper for yii2

Widget page, (*1)

Bootstrap Tree View Default, (*2)

Installation

The preferred way to install this extension is through composer., (*3)

Install

Either run, (*4)

$ php composer.phar require execut/yii2-widget-bootstraptreeview "dev-master"

or add, (*5)

"execut/yii2-widget-bootstraptreeview": "dev-master"

to the require section of your composer.json file., (*6)

Simple example

use execut\widget\TreeView;
use yii\web\JsExpression;

$data = [
    [
        'text' => 'Parent 1',
        'nodes' => [
            [
                'text' => 'Child 1',
                'nodes' => [
                    [
                        'text' => 'Grandchild 1'
                    ],
                    [
                        'text' => 'Grandchild 2'
                    ]
                ]
            ],
            [
                'text' => 'Child 2',
            ]
        ],
    ],
    [
        'text' => 'Parent 2',
    ]
];

$onSelect = new JsExpression(<<<JS
function (undefined, item) {
    console.log(item);
}
JS
);
$groupsContent = TreeView::widget([
    'data' => $data,
    'size' => TreeView::SIZE_SMALL,
    'header' => 'Categories',
    'searchOptions' => [
        'inputOptions' => [
            'placeholder' => 'Search category...'
        ],
        'clearButtonOptions' => [
            'title' => 'Clear',
        ],
    ],
    'clientOptions' => [
        'onNodeSelected' => $onSelect,
        'selectedBackColor' => 'rgb(40, 153, 57)',
        'borderColor' => '#fff',
    ],
]);


echo $groupsContent;

Pjax navigation example

use yii\widgets\Pjax;
use yii\web\JsExpression;
use execut\widget\TreeView;
use yii\helpers\Url;
Pjax::begin([
    'id' => 'pjax-container',
]);

echo \yii::$app->request->get('page');

Pjax::end();

$onSelect = new JsExpression(<<<JS
function (undefined, item) {
    if (item.href !== location.pathname) {
        $.pjax({
            container: '#pjax-container',
            url: item.href,
            timeout: null
        });
    }

    var otherTreeWidgetEl = $('.treeview.small').not($(this)),
        otherTreeWidget = otherTreeWidgetEl.data('treeview'),
        selectedEl = otherTreeWidgetEl.find('.node-selected');
    if (selectedEl.length) {
        otherTreeWidget.unselectNode(Number(selectedEl.attr('data-nodeid')));
    }
}
JS
);

$items = [
    [
        'text' => 'Parent 1',
        'href' => Url::to(['', 'page' => 'parent1']),
        'nodes' => [
            [
                'text' => 'Child 1',
                'href' => Url::to(['', 'page' => 'child1']),
                'nodes' => [
                    [
                        'text' => 'Grandchild 1',
                        'href' => Url::to(['', 'page' => 'grandchild1'])
                    ],
                    [
                        'text' => 'Grandchild 2',
                        'href' => Url::to(['', 'page' => 'grandchild2'])
                    ]
                ]
            ],
        ],
    ],
];

echo TreeView::widget([
    'data' => $items,
    'size' => TreeView::SIZE_SMALL,
    'clientOptions' => [
        'onNodeSelected' => $onSelect,
    ],
]);

Changing widget template

You can redefine widget template via template option:, (*7)

echo TreeView::widget([
    ...
    'template => TreeView::TEMPLATE_SIMPLE,
    //'template => TreeView::TEMPLATE_ADVANCED //by default
    ...
]);

Supported template parts:, (*8)

Key Description
{header} 'header' configuration widget param
{search} Search input
{tree} Bootstrap TreeView widget content

License

yii2-widget-bootstraptreeview is released under the Apache License Version 2.0. See the bundled LICENSE.md for details., (*9)

The Versions

02/04 2018

dev-master

9999999-dev https://github.com/execut/yii2-widget-bootstraptreeview

Bootstrap Tree View widget wrapper for yii2

  Sources   Download

Apache-2.0

The Requires

 

by Avatar eXeCUT

plugin extension yii2 jquery form bootstrap input tree

02/04 2018

1.1.6

1.1.6.0 https://github.com/execut/yii2-widget-bootstraptreeview

Bootstrap Tree View widget wrapper for yii2

  Sources   Download

Apache-2.0

The Requires

 

by Avatar eXeCUT

plugin extension yii2 jquery form bootstrap input tree

22/06 2017

1.1.4

1.1.4.0 https://github.com/execut/yii2-widget-bootstraptreeview

Bootstrap Tree View widget wrapper for yii2

  Sources   Download

Apache-2.0

The Requires

 

by Avatar eXeCUT

plugin extension yii2 jquery form bootstrap input tree

27/11 2015

1.1.2

1.1.2.0 https://github.com/execut/yii2-widget-bootstraptreeview

Bootstrap Tree View widget wrapper for yii2

  Sources   Download

Apache-2.0

The Requires

 

by Avatar eXeCUT

plugin extension yii2 jquery form bootstrap input tree

23/11 2015

dev-development

dev-development https://github.com/execut/yii2-widget-bootstraptreeview

Bootstrap Tree View widget wrapper for yii2

  Sources   Download

Apache-2.0

The Requires

 

by Avatar eXeCUT

plugin extension yii2 jquery form bootstrap input tree