Yii 1.1: silcom-tree-grid-view

CGridView as a tree

This extension provides a tree view in a CGridView.

I made it because i tried to use several from Yii extension for this purpose and none of them worked for me. Probably there are a few bugs.


Yii 1.1 or above


Download extension from downloads and upload into the extensions folder

$this->widget('ext.SilcomTreeGridView.SilcomTreeGridView', array(


Using http://ludo.cubicphuse.nl/jquery-treetable/

Change Log September 29, 2014

Minor correction in function that order the nodes

September 02, 2014

Initial release.

Total 3 comments

#18965 report it
vishun at 2015/02/13 10:14pm

It work well.thanks. some tips:
1.you should add

$dataProvider=new CActiveDataProvider('XXX');

and so on in your controller.
2.if your root parent_id is 0,change line57:

if ($node->{$this->parentColumn} == null)


if ($node->{$this->parentColumn} == 0)

3.if you want add filter,can do like this ext:http://www.yiiframework.com/extension/mctreegridview/.and change this code in lin 62:

if (count($orderedData) == 0){throw new Exception("Error, no roots found");}

should not throw error :

if (count($orderedData) == 0){return $orderedData;}

filter not work very well,if keep the parent followed by children,It can only filter some specially column,could't search children and if parent and children has different status,filter failed ,.if anyone can solve it,please tell me ,or the author @Bianchi add filter function?
4.if you want this look like CGriview css.you can change lin 186:

$row .= ' ' . $this->parentClass . $this->rowCssClass[$rowIndex % $n];

to this:

$row .= ' ' . $this->rowCssClass[$rowIndex % $n];

or define css yourself.

above this,I'm new about this,so I'm not sure it correct ,if there is mistake please point out.

#18219 report it
Bianchi at 2014/09/29 07:34am

Thanks for the suggestion, it was added a new file with it

#18217 report it
tomh at 2014/09/29 12:18am
Very handy - just what I needed.

Thanks for this - I like what you've done. It works almost flawessly.

One minor issue is that the following line:

if ($insertedNode->getPrimaryKey() == $node->{$this->parentColumn}) {

should read:

if ($insertedNode->getPrimaryKey() == $node->{$this->parentColumn} &&
                        in_array($insertedNode, $oldOrderedData)) {

To ensure newly added nodes do not have their children inserted until the next loop, otherwise the ordering of nodes can get out of order.

Leave a comment

Please to leave your comment.

Create extension