koperdog/yii2-treeview

小部件,用于以网格形式显示 ns 树

安装次数: 463

依赖项: 0

建议者: 0

安全: 0

星标: 2

关注者: 1

分支: 1

开放性问题: 1

类型:yii2-extension

1.0.1 2020-02-05 07:12 UTC

This package is auto-updated.

Last update: 2024-09-05 22:09:57 UTC


README

小部件,用于以网格形式显示嵌套集合树

基于 GridView

Packagist Packagist Version PHP from Packagist

preview

安装

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

运行以下命令之一

php composer.phar require --prefer-dist koperdog/yii2-treeview "*"

或者将以下内容添加到您的 composer.json 文件的 require 部分:

"koperdog/yii2-treeview": "*"

用法

添加到您的模型字段

public $children = null;

与 GridView 具有相同的设置。

echo koperdog\yii2treeview\TreeView::widget([
	'dataProvider'  => $dataProvider,
	//'depthPrefix' => ' — ', //see Additional options
	//'depthRoot'   => 1, //see Additional options
	//'collaplse'   => true, //see Additional options
	'columns' => [
	  'id',
	  'name',
	  'created_at:datetime',
	  // ...
	],
    ]);

列类与 GridView 相同

['class' => '\koperdog\yii2treeview\base\CheckboxColumn'],
['class' => '\koperdog\yii2treeview\base\ActionColumn'],
['class' => '\koperdog\yii2treeview\base\RadioButtonColumn'],
['class' => '\koperdog\yii2treeview\base\SerialColumn'],
附加选项
depthPrefix - 显示深度的前缀(默认 " — ")
depthRoot - 从根的偏移量(默认 0)
collaplse - 如果为 true,它将为节点元素添加 "closed" 类,并将 "tree-collapse" 添加到树的根(默认 false)