yii2-widget-bootstraptreeview Bootstrap Tree View widget wrapper for yii2

Bootstrap Tree View widget wrapper for yii2

  1. Installation
  2. Usage
  3. License

Wrapper home page Widget home page

Installation

The preferred way to install this extension is through composer.

Install

Either run

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

or add

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

to the `require` section of your composer.json file.

Usage

use execut\widget\TreeView;

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

$onSelect = new \yii\web\JsExpression(<<<JS
function (undefined, item) {
    $.pjax({
        container: '#pjax-container',
        url: item.href,
        timeout: null
    });
}
JS
);
$groupsContent = TreeView::widget([
    'data' => $data,
    'size' => TreeView::SIZE_SMALL,
    'clientOptions' => [
        'onNodeSelected' => $onSelect,
        'selectedBackColor' => 'rgb(40, 153, 57)',
        'borderColor' => '#fff',
    ],
]);

License

yii2-widget-bootstraptreeview is released under the Apache License Version 2.0. See the bundled LICENSE.md for details.

1 0
4 followers
0 downloads
Yii Version: 2.0
License: Apache-2.0
Category: User Interface
Developed by: eXeCUT
Created on: Apr 27, 2015
Last updated: 3 years ago

Related Extensions