wodrow / yii2-wwtree
另一款分类树编辑管理工具
Installs: 79
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- php: >=7.1
- kartik-v/yii2-icons: ^1.4.5
- kartik-v/yii2-widget-activeform: ^1.5.8
- kartik-v/yii2-widget-colorinput: ^1.0.5
- kartik-v/yii2-widget-select2: ^2.1.6
- wodrow/yii2wtools: ^0.1.18
This package is auto-updated.
Last update: 2024-11-08 16:26:39 UTC
README
使用方式
安装
composer require wodrow/yii2-wwtree dev-master
模型
public function behaviors() { return [ 'tree' => [ 'class' => \wodrow\yii2wwtree\TreeBehavior::class, 'primaryKeyAttribute' => 'your_pk_id_filed_name', 'parentKeyAttribute' => 'your_parent_id_filed_name', 'nameKeyAttribute' => 'your_name_filed_name', 'sortKeyAttribute' => 'your_sort_filed_name', 'iconKeyAttribute' => 'your_icon_filed_name', 'iconColorKeyAttribute' => 'your_icon_color_filed_name', ], ]; }
视图
<?=wodrow\yii2wwtree\TreeWidget::widget([ 'treeModelClass' => "your model class", // 'custom_field_view' => "@your/extend/view", // 'ajaxUrl' => "", ]) ?>
注意
数据表必须要有id, pid(父级), name, sort, icon, icon_color这六个字段,字段名可以是TreeBehavior配置的字段名; 其他字段根据需要自己添加, 在custom_field_view视图里可以处理添加的字段,使用它生成的模型。 如果使用ajaxUrl,推荐在控制器添加actions public function actions() { return [ ..., 'to-your-ajax-url' => [ 'class' => \wodrow\yii2wwtree\SearchAction::class, 'searchClass' => TestTree::class, 'idKeyAttr' => 'your id field key', 'textKeyAttr' => 'your text field key', ], ]; }