HOW to add an special attribute to the filter area in CGridView

Hi, I have this CGridView configuracion for my Model:


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

	'id' => 'cuota-grid',

	'dataProvider' => $model->search(),

	'filter' => $model,

	'columns' => array(

		//'id',

		'tipo_cuota',

		'anio_calendario',

		'mes_calendario',

		array('name'=>'fkAlumno.LegajoYApellidoYNombre',

			'header'=>'Alumno',

			'filter'=>GxHtml::listDataEx(Alumno::model()->findAllAttributes(null, true)),

			),

		array('name'=>'fkGrado.descripcion','header'=>'Grado'),

		'importe',

		'importe_pagado',

		'importe_beca',

		'estado',

		/*

		'fk_cuenta_contable_id',

		'nro_transaccion',

		'descripcion',

		

		

		'beca',

		

		

		*/

		array(

			'class' => 'CButtonColumn',

			'template'=>'{view}{delete}',

		),

	),

)); ?>

As you can see, I have a related field (LegajoYApellidoYNombre), this fiels is a calculated field in the Model Alumno:


	public function getLegajoYApellidoYNombre() {

		return $this->legajo_numero.' - '.$this->apellido.', '.$this->nombre;

	}



In the CGridView I didn’t see any text field above the columns data …

I also alter search in Cuota model:


		//$criteria->compare('fk_alumno_id', $this->fk_alumno_id);

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



And also added thse field to “safe” in rules of Alumno’s model:


array('LegajoYApellidoYNombre', 'safe'),

What I’am doing wrong ?

Best Regards

Hi, xNicox,

This is one of the best wiki articles, IMO. And I hope it will help you, too.

http://www.yiiframework.com/wiki/281/searching-and-sorting-by-related-model-in-cgridview