Filter For Cdatacolumn

Hey,

i use a CDataColumn in my GriedView:


				array(

					'class' => 'CDataColumn',

					'header' => 'Rating',

					'filter' => CHtml::textField('Text'),

					'value' => function($model){return $model->getValue();},

				),



I want to use a Filter for this Column, so i set the filter value of the Column array. However there is a Textfield placed to search for this Column but the filter doesent work. I think i have to customize the "search" method of my model cause i use it as dataProvider for the Grid. But im a bit confused how i can do this.

My Controller action looks in this manner:




		$provider = $model->search();

		

		$this->render('my_view',array( 

			'dataProvider'=>$provider,

			'model' => $model

		));



Can someone give me an advice how i can make the CDataColumn workable for me?

Is ‘value’ the attribute of the model you want to display as column in the gridview?

Why you don’t use the standard CGridView implementation like below?

You don’t need to create an extra CDataColumn to show a filter input.

Assign the model as filter property to enable the column-based filtering.




$this->widget('zii.widgets.grid.CGridView', array(

    'dataProvider'=>$dataProvider,

    'filter'=>$model,     

    'columns'=>array(

        'value',          // display the 'value' attribute with filter

        ...

    ),

));




Assign ‘Rating’ as label in the method ‘attributeLabels’ of the model or




$this->widget('zii.widgets.grid.CGridView', array(

    'dataProvider'=>$dataProvider,

    'filter'=>$model,

    'columns'=>array(

         array(

            'name' => 'value',

            'header' => 'Rating',

        ),

        ...

    ),

));