yii2mod/yii2-tree

基于 Fancytree 插件的树形控件。

安装次数: 47,349

依赖者: 0

建议者: 0

安全: 0

星标: 21

关注者: 9

分支: 3

开放性问题: 1

类型:yii2-extension

1.3.2 2017-11-23 10:58 UTC

This package is not auto-updated.

Last update: 2024-09-17 04:23:22 UTC


README

Yii2 Tree Widget


基于 Fancytree 扩展的树形控件 http://wwwendt.de/tech/fancytree/demo/#sample-default.html

Latest Stable Version Total Downloads License Build Status

安装

安装此扩展的首选方式是通过 composer

运行以下命令之一

php composer.phar require --prefer-dist yii2mod/yii2-tree "*"

或者

"yii2mod/yii2-tree": "*"

将以下内容添加到你的 composer.json 文件的 require 部分中。

用法

安装扩展后,只需将控件添加到页面中,如下所示

<?php echo yii2mod\tree\Tree::widget([
            'items' => [
                ['title' => 'Category 1'],
                ['title' => 'Category 2'],
                [
                    'title' => 'Category 3',
                    'children' => [
                        [
                            'title' => 'Category 3.1',
                        ],
                        [
                            'title' => 'Category 3.2',
                            'children' => [
                                [
                                    'title' => 'Category 3.2.1',
                                ]
                            ],
                            'folder' => true,
                        ],
                    ],
                    'folder' => true,
                ],

            ],
            'clientOptions' => [
                'autoCollapse' => true,
                'clickFolderMode' => 3,
                'activate' => new \yii\web\JsExpression('
                        function(node, data) {
                              node  = data.node;
                              // Log node title
                              console.log(node.title);
                        }
                '),
            ],
        ]); ?>

你还可以更改 Fancytree 扩展的主题!

要更改主题,可以在应用程序配置中配置 assetManager 数组

// skin-win8

'assetManager' => [
    'bundles' => [
        'yii2mod\tree\TreeAsset' => [
            'css' => [
                'skin-win8/ui.fancytree.less',
            ]
        ],
    ],
]