lesha724 / yii2-bootstrap-tree
基于 bootstrap-treeview 的小部件
v1.1.1
2018-01-19 11:02 UTC
Requires
- bower-asset/patternfly-bootstrap-treeview: ^2.1
- yiisoft/yii2: *
- yiisoft/yii2-bootstrap: *
README
用于 bootstrap-treeview 的小部件
安装
安装此扩展的首选方式是通过 composer.
运行以下命令之一:
php composer.phar require --prefer-dist lesha724/yii2-bootstrap-tree "*"
或添加
"lesha724/yii2-bootstrap-tree": "*"
到您的 composer.json
文件的 require 部分中。
使用方法
扩展安装完成后,只需在您的代码中通过以下方式使用它:
<?php // Example of data. $items structure https://github.com/patternfly/patternfly-bootstrap-treeview#data-structure $items = [ [ 'text' => 'Node 1' 'icon' => "glyphicon glyphicon-stop", 'selectedIcon' => "glyphicon glyphicon-stop", 'href' => "#node-1", 'selectable' => true, 'state' => [ 'checked' => true, 'disabled' => true, 'expanded' => true, 'selected' => true ], 'tags' => ['available'], ..., 'nodes'=> [ ... ] ], [ 'text' => 'Folder 2', 'nodes' => [ ['text' => 'Node 2.1'], ['text' => 'Node 2.2'] ] ] ]; ?> <?= \lesha724\bootstraptree\TreeView::widget([ 'htmlOptions'=>[ 'id'=>'treeview-tabs' ], 'options'=>[ //https://github.com/patternfly/patternfly-bootstrap-treeview#options 'data'=>$items, 'enableLinks'=>true, 'showTags'=>true, 'levels'=>3 ], 'events'=>[ //https://github.com/patternfly/patternfly-bootstrap-treeview#events 'onNodeSelected'=>'function(event, data) { // Your logic goes here alert(data.href); }' ] ]); ?>