I am still very new to yii1 and fight now with a GridView. I have build a Search Form and when sending of the form, the page gets re-loaded and the GridView shows up with the results. The form goes to the Controller action and gets the appropriate records.
That works well, besides Pagination. As soon I click on the next page, the GridView is empty, if I refresh the Page, the GridView shows the results for that page. What am I doing wrong here? I have printed out the $dataProvider in my view and it seems to hold all the data, but the table shows no records. Any hint what I am doing wrong? I really hope someone can help. Thank you so much !
What is the complete lines for the controller? CGridview ajax works as GET (default) not POST. While your form might be using POST. I am not sure but it might be your problem.
Unfortunately, my problem with the pagination is still not solved, so I am wondering if anyone here got any more ideas.
Please see a few more information from my controller and Model:
myController.php
$newArticles = $articles->searchArticles();
// below needs to be done since it gets combined with articles from another section
$allArticles = array_intersect($prevArticles,$newArticles );
$criteria = new CDbCriteria;
$criteria->addInCondition('t.id', $allArticles);
$dataProvider = new CActiveDataProvider('MyModel', array(
'criteria'=>$criteria,
));
$this->render('overallSearch',
array(
'model'=>$model,
'dataProvider'=>$dataProvider,
));
myModel.php
public function searchArticles()
{
// GET THE ARTICLES FROM THE DB....
$criteria->addInCondition('t.id', $foundArticles);
return array('criteria' => $criteria, 'sort' => $sort);
}