cgridview and external parameter

Hi, im trying to use the


 $data->property 

as an index inside an array, the array i passed from the controller like this:


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

			'mision'=>$mision,

			'model'=>$model,

			'estados'=> array('Pendiente','Entregado','Liquidado'),

			));

but, i cant access it from the cgridview:




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

	'id'=>'solicitudes-grid',

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

	'filter'=>$model,

	'columns'=>array(

		'sol_id',

		'sol_fecha',

		array(

		  	'header'=>'Estado',

		  	'type'=>'raw',

		  	'value'=>'$estados[$data->sol_estado]',),

		'sol_estado',

		array(

			'class'=>'CButtonColumn',

			'template'=>'{view}',

		),

	),

)); 



can anybody help me with this?

CDataColumn can access only 3 local variables in its statement for ‘value’ property:

  1. $data … row contents

  2. $row … row number

  3. $this … CDataColumn instance itself

So ‘$data->sol_estado’ is OK, but $estados is not.

One thing you can make use of is $this. It can retrieve its parent CGridView by $this->grid.

And the CGridView instance can retrireve its parent controller by its property ‘controller’.

So if you define your ‘estados’ as a public property of your controller, then it can be retrieved as ‘$this->grid->controller->estados’.

The other thing you can make use of is static functions and/or static variables of various classes.

I think it could be the model class in your case, i.e., ‘SomeModel::$estados’ or 'SomeModel::getEstado($sol_estrado).

Hi, i tried the public property approach, and it worked perfectly!!! thanks a lot!