Hola, Gracias a los 2 por contestar.
Aún no me funciona, traté de hacer como estaba tu respuesta a18327 te muestro como lo tengo:
el modelo
class Ciudad extends CActiveRecord
private $_nombredepartamento;
:::
array('idciudad, ciudadcod, nombreciudad, departamento_iddepartamento, fechaingreso, nombredepartamento', 'safe', 'on'=>'search'),//function rules
:::
'departamento_iddepartamento' => array(self::BELONGS_TO, 'Departamento', 'departamento_iddepartamento'),//function relations
:::
public function searchDepto()
{
// @todo Please modify the following code to remove attributes that should not be searched.
$criteria=new CDbCriteria;
$criteria->with=array('departamento_iddepartamento.iddepartamento');
$criteria->compare('iddepartamento.nombredepartamento',$this->nombredepartamento, true);
$criteria->compare('idciudad',$this->idciudad);
$criteria->compare('ciudadcod',$this->ciudadcod,true);
$criteria->compare('nombreciudad',$this->nombreciudad,true);
$criteria->compare('departamento_iddepartamento',$this->departamento_iddepartamento);
$criteria->compare('fechaingreso',$this->fechaingreso,true);
$sort=new CSort();
$sort->attributes=array(
'nombredepartamento'=>array(
'asc'=>'iddepartamento.nombredepartamento ASC',
'desc'=>'iddepartamento.nombredepartamento DESC',
),
'*',
);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
'sort'=>$sort,
));
}
public function getDepto(){//<-------La funcion get
if(!isset($this->_nombredepartamento)){
if(isset($this->departamento_iddepartamento)){
if(isset($this->departamento_iddepartamento->iddepartamento)){
$this->nombredepartamento=$this->departamento_iddepartamento->iddepartamento->nombre_departamento;
}
}
}
return $this->_nombredepartamento;
}
public function setDepto($nombredepartamento){//<----------La funcion set
$this->nombredepartamento=$nombredepartamento;
}
la vista:
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'ciudad-grid',
'dataProvider'=>$model->searchDepto(),
'filter'=>$model,
'columns'=>array(
'idciudad',
'ciudadcod',
'nombreciudad',
array(
'name'=>'nombredepatamento',
//'value'=>'$data->departamento->departamento_iddepartamento',
),
//'nombre'=>array(
//'name'=>'departamento_iddepartamento',
//'value'=>'',
// ),
'fechaingreso',
array(
'class'=>'CButtonColumn',
),
Agredecería tu ayuda de nuevo.
Me sale: La propiedad "Ciudad"."nombredepartamento" no se encuentra definida.
ahora intentaré lo que dice Roberto Zamarripa
Gracias