gridview dropdown filter

Hope someone can help me:

I have a table called ‘reference’ with a field called ‘article_type’, which i want to attach a dropdown filter to because it has only two possible values, ‘research’ or ‘review’.

here is the relevant model with ‘$criteria->compare(‘article_type’,$this->article_type);’:

public function search()

{


	// @todo Please modify the following code to remove attributes that should not be searched.





	$criteria=new CDbCriteria;





	


	$criteria->compare('gdoc_ref_id',$this->gdoc_ref_id);


	$criteria->compare('date',$this->date);


	$criteria->compare('abstract',$this->abstract,true);


	$criteria->compare('summary',$this->summary,true);


	$criteria->compare('full_ref',$this->full_ref,true);


	$criteria->compare('toxin_type',$this->toxin_type,true);


	$criteria->compare('article_type',$this->article_type); 





	return new CActiveDataProvider($this, array(


		'criteria'=>$criteria,


		'pagination' => array( 'pageSize' => 10 ),


	));


} 

AND HERE IS MY VIEW (see ‘test dropdown’ in the column array):

<?php $this->widget(‘zii.widgets.grid.CGridView’, array(

'id'=&gt;'reference-grid',


'dataProvider'=&gt;&#036;model-&gt;search(),


'filter'=&gt;&#036;model,


// these are the visible columns in the gridview table and their order


'columns'=&gt;array(


	


	array( 


		   'name' =&gt; 'gdoc_ref_id',


		   'type' =&gt; 'raw',


		   'value' =&gt; 'CHtml::link(CHtml::encode(&#036;data-&gt;gdoc_ref_id), Yii::app()-&gt;request-&gt;baseUrl . &quot;/pdf/&quot; . 


		   	CHtml::encode(&#036;data-&gt;gdoc_ref_id). &quot;.pdf&quot;, array(&quot;target&quot;=&gt;&quot;_blank&quot;))', 


		  ),  





	'date',


	'toxin_type',


	'abstract',


	


	[b]//test dropdown[/b]

NOTE: THIS FILTERS FINE IF i USE ‘NAME’ AND REMOVE FILTER, SO I AM ASSUMING MY MODEL IS FINE BUT JUST NOT ASSOCIATING THE DROPDOWN BOX WITH THE MODEL ????

array(

//'name'=&gt;'article_type', // this filters fine when i use it to replace 'filter'


'value'=&gt;'&#036;data-&gt;article_type',


 'filter' =&gt; CHtml::dropDownList(


	'article_type', 


	&#036;model-&gt;article_type, 


	array('review' =&gt; 'Review', 


	'research' =&gt; 'Research',), 


	array('empty' =&gt; '(Select)')) 


	), 

array(

                'class'=&gt;'CButtonColumn',


                    'template'=&gt;'{view}',


                    'header' =&gt; 'Details',





                    'buttons'=&gt;array(


                                    


                                    'view'=&gt;array(


                                                    'visible'=&gt;'true',


                                            ),


                                    


                    ),


           ),











),

));

Since I am not getting any feedback on my problem, I assume that I have confused everyone. Instead of finding the problem in my code, let me just ask if someone could post how to put a drawdown box as a filter at the top of a gridview column.

My table is called reference, the field is called article_type.

just to show you where my head is on this, i am adding the below info.

The relevant code in the ‘search’ function in the Model is: $criteria->compare(‘article_type’,$this->article_type);

What I have as a gridview column in the View file is:

array(

'value'=&gt;'&#036;data-&gt;article_type',


'header'=&gt; 'Article Type',


 'filter' =&gt; CHtml::dropDownList(


	'reference[article_type]',


	&#036;model-&gt;article_type, 


	array('Review' =&gt; 'Review', 


	'Research' =&gt; 'Research',), 


	array('empty' =&gt; '(Select)')) 


	),

As it stands, I get the box and when I choose a value the filtering takes place- but it sees the box as if it were empty- i.e. no value associated with it…

thanks

Have you tried just passing an array to the filter key? This way, cgridview should generate the dropdown for you with the appropriate name/id values based off your column’s name value:




array(

	'name' => 'article_type',

	'filter' => array(

		'review' => 'Review',

		'research' => 'Research',

	),

),