i had clone search function into model, use it in controller pass to my view to use CGridview, the result data is correct but filters stop working, i can't see any difference so there must be something more else to add. This are the sections of my code: Model:
public function searchCargo()
{
$criteria=new CDbCriteria;
$criteria->compare('cargoResp',1,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
Controller
$modRespSearchC=new Responsables('searchCargo');
$modRespSearchC->unsetAttributes();
if(isset($_GET['Responsables']))
$modRespSearchC->attributes=$_GET['Responsables'];
CGridView:
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'responsables-grid1',
'dataProvider'=>$modRespSearchC->searchCargo(),
'filter'=>$modRespSearchC,
'columns'=>array(
'apell1Resp',
'apell2Resp',
'cargoResp',.....
what i had miss?? how can use filters with my own functions??
The other search conditions are missing. However since they exist in the search
function all you need to do is call that function as below:
public function searchCargo() {
$dataProvider = $this->search();
$dataProvider->criteria->compare('cargoResp',1,true);
return $dataProvider;
}
Also unless you have added rules for searchCargo
in your model's rules
method, your scenario should be search
i.e
$modRespSearchC=new Responsables('search')