Hello everyone !
I have a problem with my CGridView pagination.
I use a CArrayDataProvider as data provider.
When changing page, I get a blank page (ajax on) or I’m back to my search form (ajax off).
I think I know what the problem is : in my controller, I check if $_POST[‘Model’] is set (for validation), and I use the data from the post to perform the search.
When I change page, $_POST[‘Model’] isn’t set anymore, so my controller sends me back to a search form with a new model :
public function actionSearch()
{
$lFiche = new Fiche();
$lDataProvider = null;
//Validation Ajax
if(isset($_POST['ajax']) && $_POST['ajax']==='searchForm')
{
echo CActiveForm::validate($lFiche);
Yii::app()->end();
}
//Validation serveur
if(isset($_POST['Fiche']))
{
$lFiche->attributes = $_POST['Fiche'];
// Valide l'entrée de l'utilisateur
if($lFiche->validate())
{
/*Analyse des données remplies dans le formulaire de recherche
* dans l'ordre suivant :
* 1 -> Code interne
* Si code interne vide :
* 2 -> Libellé et province
* Si libellé et province vide :
* 3 -> retour d'un résultat vide
*/
if(!empty($_POST['Fiche']['codeInt']))
$lDataProvider=Fiche::SearchByCode($_POST['Fiche']['codeInt']);
else if(!empty($_POST['Fiche']['libelle']) || !empty($_POST['Fiche']['province']))
$lDataProvider=Fiche::SearchByLibLoc($_POST['Fiche']);
$this->render('searchResult', array('fiches' => $lDataProvider));
}
else
$this->render('searchForm', array('fiche' => $lFiche));
}
else
$this->render('searchForm', array('fiche' => $lFiche));
}
How can I handle that problem ?
By the way, I can’t use CActiveDataProvider as I don’t use ActiveRecords (my models aren’t related to a db table).