mark2bra
(Mark2bra)
May 21, 2014, 3:12pm
1
I was asked to show a list of events in a CgridView , and to add a dropdown hat will filter them by week/date.
Now , my first thought was to use the "advanced search" , but the value I need to filter by is in another related model.
So question number 1: can I add a relation filter in the advanced search form page?
If ,not , i created the following dropdown:
$week=CHtml::listData(Week::model()->findAll(array('order'=>'start_date DESC')), 'id','number','start_date');
echo CHtml::dropDownList('weeks', $week, $week, array('empty' => ''));
which is working , but not I don’t know how to pass the selected value to the gridView’s search condition which is in the same page (preferably without the need of a button click)
'dataProvider'=>$model->search(array('condition'=>'confirmed=0')),
Any ideas about both options?
Thanks,
Mark.
this article is along the lines of what you are looking for I think
I was asked to show a list of events in a CgridView , and to add a dropdown hat will filter them by week/date.
Now , my first thought was to use the "advanced search" , but the value I need to filter by is in another related model.
So question number 1: can I add a relation filter in the advanced search form page?
If ,not , i created the following dropdown:
$week=CHtml::listData(Week::model()->findAll(array('order'=>'start_date DESC')), 'id','number','start_date');
echo CHtml::dropDownList('weeks', $week, $week, array('empty' => ''));
which is working , but not I don’t know how to pass the selected value to the gridView’s search condition which is in the same page (preferably without the need of a button click)
'dataProvider'=>$model->search(array('condition'=>'confirmed=0')),
Any ideas about both options?
Thanks,
Mark.
If you are about to use the advanced search, maybe you can use join table.
Refer this http://www.yiiframework.com/forum/index.php/topic/54569-cgridview-filter-and-sql-errore/page__view__findpost__p__250629
mark2bra
(Mark2bra)
May 23, 2014, 10:56am
6
I ended up using the related model in the search form.
Worked!
Thanks you all.
Cheers,
mark.