Documentation ¶
Requirements ¶
- Yii 1.0 or above
Installation ¶
- Extract the release file under
protected/extensions
Usage ¶
See the following code example: ~~~ //in model public function behaviors() {
return array(
'TreeBehavior' => array(
'class' => 'ext.tree.behaviors.TreeBehavior',
'id'=>'id', 'parent_id'=>'parent_id', ...
),
);
}
//in controller
public function actions() {
return array(
'treeMoveUp'=>'ext.tree.actions.TreeMoveUpAction',
'treeMoveDown'=>'ext.tree.actions.TreeMoveDownAction',
'treeCreate'=>'ext.tree.actions.TreeCreateAction',
'treeUpdate'=>'ext.tree.actions.TreeUpdateAction',
'treeLoad'=>'ext.tree.actions.TreeLoadAction',
'treeDelete'=>'ext.tree.actions.TreeDeleteAction',
'treeChildren'=>'ext.tree.actions.TreeChildrenAction',
'treeChildrenParent'=>'ext.tree.actions.TreeChildrenParentAction',
);
}
public function actionAdmin() {
$this->render('admin');
}
//in admin[view]
$this->widget('ext.tree.widgets.TreeWidget',array('modelName'=>'YOur treeModel'));
//default tree schema
CREATE TABLE IF NOT EXISTS tree
(
id
int(11) NOT NULL AUTO_INCREMENT,
lft
int(11) NOT NULL,
rgt
int(11) NOT NULL,
level
int(11) NOT NULL,
parent_id
int(11) NOT NULL,
name
varchar(256) NOT NULL,
PRIMARY KEY (id
)
)
~~~
请下载tree.v2.zip,谢谢
Change Log ¶
April 6, 2010 ¶
- Initial release.
新版修改了几处BUG
新版修改了几处BUG,同时增加了TreeSelectWidget,欢迎大家试用。
如果没能及时处理大家的问题,请访问
http://71151461.cn/?p=222
A better solution is CTreeView
http://www.yiiframework.com/doc/cookbook/70/
小用了一下,赞一个~qq71151461
目前提出两个问题:
1、admin管理树时,没有将节点往上级或下级移动的能力,且目前的方式,感觉不够直观
2、针对第一个问题,使用select控件,感觉也比较难以实现,我的建议是使用 jsTree(js组件)来做这个管理功能,jsTree拥有非常强大的api支持,希望可以搭配使用~
非常感谢分享你的成果~~~
English..
English comments but chinese form + error makes no sense :(
节点移动有问题
比如以下数据
1
1.1
1.1.1
2
2.1
将2.1 移动到1.1.1就出错了。
very Nice
[php] <?php $this->widget('ext.tree.widgets.TreeWidget',array('modelName'=>'YOur treeModel'));?>[php]
example:
model is User.php
$this->widget('ext.tree.widgets.TreeWidget',array('modelName'=>'user'));
fix a bug:
'treeMoveDown'=>'myext.tree.actions.TreeMoveDownAction',
should be
'treeMoveDown'=>'ext.tree.actions.TreeMoveDownAction',
other, if u left is blank:
you should comment
//'actions'=>array('index','view'),
and if u cant add a new record,plz comment
//array('lft, rgt, level, parent_id, name', 'required'),
Re: can you update your extension for english comments/errors?
If I may make a suggestion, I installed the Google Translate extension on my browser (Chrome) and use it frequently while here. It helps a lot...
can you update your extension for english comments/errors?
can you update you comments (and errors also) for english? Right now it's useless for people that don't know chinese(or korean, sorry if i'm wrong).
Thanks.
good。
支持,感谢分享
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.