Hola, gracias por la ayuda ahora me sale bien el CGridview pero al momento de buscar no me funciona debe ser por que la funcion filter no esta bien? te coloco mi codigo por favor necesito ayuda no puedo utilizar modelos solo arrays:
CFormModel
class MarcaForm extends CFormModel
{
public $filters = array();
/**
* Override magic getter for filters
*/
public function __get($name)
{
if(!array_key_exists($name, $this->filters))
$this->filters[$name] = null;
return $this->filters[$name];
}
public function filter(array $data)
{
foreach($data AS $rowIndex => $row) {
foreach($this->filters AS $key => $value) {
// unset if filter is set, but doesn't match
if(array_key_exists($key, $row) AND !empty($value)) {
if(stripos($row[$key], $value) === false)
unset($data[$rowIndex]);
}
}
}
return $data;
}
}
Controller
$marcas=$client->getMarcas();
$filtersForm=new MarcaForm;
if (isset($_GET['FiltersForm']))
$filtersForm->filters=$_GET['FiltersForm'];
$dataProvider=new CArrayDataProvider($marcas);
// Render
$this->render('index', array('model'=>$marcas,
'filtersForm' =>$filtersForm,
'dataProvider' => $dataProvider,
));
y la vista index:
<?php
$columns = array(
array(
'header'=>CHtml::encode('Descripcion'),
'name'=>'descripcion',
'value'=>'CHtml::link($data->descripcion,array("marca/view",
"id"=>$data->id))',
),
array(
'header'=>CHtml::encode('Fecha de creacion'),
'name'=>'created_at',
'value'=>'$data->created_at',
),
);
?>
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'area-grid',
'filter'=>$model,
'dataProvider'=>$dataProvider,
'columns'=>$columns,
'filter'=>$filtersForm,
));
?>
En la parte del value de la descripcion quiero que salga un link para que se vea la marca en el view del controller pero me sale el codigho html esa seria una pregunta secundaria, lo mas importante es que no me funciona el buscar del gridview por que puede ser? me estoy guiando de este ejemplo: http://www.yiiframework.com/wiki/232/using-filters-with-cgridview-and-carraydataprovider/
Por favor si alguien me puede ayudar Gracias de antemano.