this extension combines treeview in a gridview with a fully working filter search
Requirements ¶
Yii 1.1 or above
Usage ¶
1.Generate a model
- 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(
'id'=>'category-grid',
// 'cssFile'=>false,
'ajaxUpdate' => false,
'dataProvider'=>$dataProvider,
'filter'=>$model,
'columns'=>array(
'id',
'name',
'description',
//'icon',
//'parent_id',
array(
'name' => 'parent_id',
'value'=>'(($data->parent_id==0)?"No Parent" :$data->parentCategory->name)',
),
array(
'class'=>'CButtonColumn',
'template'=>'{view}{update}{delete}',
'buttons'=>array
(
),
),
),
));
4.In your Controller
$model=new Category('search');
$dataProvider=new CActiveDataProvider('Category');
$criteria = new CDbCriteria();
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Category']))
{
foreach($_GET['Category'] as $key=>$value) {
$criteria -> compare($key, $value, true, 'AND');
}
$dataProvider = new CActiveDataProvider('Category', array('criteria' => $criteria));
}
$this->render('admin',array(
'model'=>$model,'dataProvider'=>$dataProvider
));
plz comment
i m a newbie to yii..plz comment and hit thumbsup to improve myself...
questions...
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?
no need to specify levels now
thanks for your appreciation ...it will work as it is...
nope!! there are no particular rules to build dataprovider...see the controller...
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?
Demo
Any Demo?
yes
surely..it will work as you said...you can download screenshot from downloads...
hi salsero
hi salsero , it willl work jus like you said...plz have a look at screenshots from downloads
I see!
I see!
hi stifano
hi stefano slasero..is it ok for u...?...
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!
i will try it
i will try it...
Thank's you!!!
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.
Neil
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..
Not correct when rows no ii order
If you will add nodes to parent in random order, grid will be incorrect. Try it yourself.
doesn't work
Doesn't work at all on non basic grid display.
Too many hard coded piece of code :(
Try that
Try that
http://www.yiiframework.com/extension/silcom-tree-grid-view/
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!
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 separate.so,you can try @Bianchi posted http://www.yiiframework.com/extension/silcom-tree-grid-view/(this ext no filter,but you can add it like this ext) or check Resources use right left (not parent_id)mothed
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.