A modification of cqtreeview,combining treeview and cgridview with filter search enabled

this extension combines treeview in a gridview with a fully working filter search


Yii 1.1 or above


1.Generate a model

  1. Add the widget to yourview

3.Download extension from downloads and upload into the extensions folder

//instead of zii.widgets.grid.CGridView a new extension CQTreeGridView is used here
$this->widget('ext.QTreeGridView.CQTreeGridView', array(
    // 'cssFile'=>false,
    'ajaxUpdate' => false,
            'name' => 'parent_id',
            'value'=>'(($data->parent_id==0)?"No Parent" :$data->parentCategory->name)',

4.In your Controller

$model=new Category('search');
         $dataProvider=new CActiveDataProvider('Category');
         $criteria = new CDbCriteria();
        $model->unsetAttributes();  // clear any default values
               foreach($_GET['Category'] as $key=>$value) {
                    $criteria -> compare($key, $value, true, 'AND');
               $dataProvider = new CActiveDataProvider('Category', array('criteria' => $criteria));


qtreeview extension original source in russian

Total 18 comments

#18964 report it
vishun at 2015/02/13 08:12pm
Hi kkk

@Kkk,you can update lastest jquery.ui.core.min.js. but the drag function maybe need other works. this a greate ext,but the most problem is it can not sort,you could not order by parent and child if parent and child,you can try @Bianchi posted ext no filter,but you can add it like this ext) or check Resources use right left (not parent_id)mothed

#18662 report it
Kkk at 2014/12/09 12:54am
TypeError: c.curCSS is not a function

Hi, the extension works, but when I click in one row and hold the button (like drag&drop in one file), it shows a javascript error in the firebug console. Then, the table breaks and shows a new "mini-row" at the end of the grid. It happens all the time!


Please! Help me!

#18054 report it
Bianchi at 2014/09/02 10:47am
Try that

Try that

#16770 report it
Revelis Luc Bonnin at 2014/03/26 08:49am
doesn't work

Doesn't work at all on non basic grid display. Too many hard coded piece of code :(

#15312 report it
howardEagle at 2013/10/27 08:46pm
Not correct when rows no ii order

If you will add nodes to parent in random order, grid will be incorrect. Try it yourself.

#13585 report it
shafi at 2013/06/08 09:40am
hi neil

is it worked for you..?.. it is the common form for all table with categories and sub categories.i m a newbie and i ll try to edit.thanks for ur comment..for the current need you please change the variable name inside extensions..

#13574 report it
AussieNeil at 2013/06/07 01:24am
Why assume that the key field is "id"

Very nice.

But why do you assume that the key field in a table is id? Line 48 Or that there is definitely going to be a field called parent_id. Line 49

Just my opinion but hardcoding values does not make this very flexible.

This should be more flexible so as to utilise the ability to set parameters. Even if you had an option that was 'id' -> 'somevariable' and 'parent_id' -> 'someothervariable' would make this much better.

Also an option to link tables rather have all the data in one table.


#13416 report it
salsero at 2013/05/28 06:57am
i will try it

i will try it... Thank's you!!!

#13415 report it
Stefano Mtangoo at 2013/05/28 06:18am
Thank you!

Its good extension but I was looking for something to organize my blog entries in dates and months like blogspot does. So as good as it is it is not suitable for that. So I might use it in future project not now. Thanks you for the work!

#13409 report it
shafi at 2013/05/28 02:14am
hi stifano

hi stefano it ok for u...?...

#13395 report it
Stefano Mtangoo at 2013/05/27 06:28am
I see!

I see!

#13393 report it
shafi at 2013/05/27 05:48am
hi salsero

hi salsero , it willl work jus like you said...plz have a look at screenshots from downloads

#13392 report it
shafi at 2013/05/27 05:46am
yes will work as you can download screenshot from downloads...

#13391 report it
Stefano Mtangoo at 2013/05/27 05:38am

Any Demo?

#13388 report it
salsero at 2013/05/27 05:13am
if i understand

if i understand:

a) in the table i insert a row with (id=5) and (parent_id = null)

=> it is root;

b) in the table i insert a row with (id=6) and (parent_id = 5)

=> it will display as son of (a);

C) in the table i insert a row with (id=7) and (parent_id = 6)

=> it will display as son of (b);

is correct?

#13387 report it
shafi at 2013/05/27 04:49am
no need to specify levels now

thanks for your appreciation will work as it is... nope!! there are no particular rules to build dataprovider...see the controller...

#13383 report it
salsero at 2013/05/27 03:21am

i really appreciate this extension but i have some questions: if my tree have 2 levels of depth, where do i specify it? there are particular rules to build dataprovider?

#13377 report it
shafi at 2013/05/26 01:35pm
plz comment

i m a newbie to yii..plz comment and hit thumbsup to improve myself...

Leave a comment

Please to leave your comment.

Create extension