0

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 is not working. 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 and moved on in my Pagination Link. 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 !

myController.php

$dataProvider = new GridDataProvider('MyModel', array(
                'criteria'=>$criteria,
              ));

$this->render('overallSearch',
                array(
                    'model'=>$model,
                    'dataProvider'=>$dataProvider,
                ));

myView.php

    $this->widget('zii.widgets.grid.CGridView', array(
        'id' =>'search-grid-new',
        'emptyText' => 'No records found',
        'htmlOptions' => array('class'=>'grid-view search-grid'),
        'dataProvider'=> $dataProvider,
        'ajaxUpdate' => true,
        'columns' => $columns,

        ));     

UPDATE

I actually thought that the problem is solved, but for some reason it is not and I am sure that I should not have to save the result in a Session anyway. Anyone any idea what I am doing wrong?

Luka
  • 748
  • 2
  • 9
  • 36
  • We need to find what went wrong first. Since 'ajaxUpdate' => true, the grid would use ajax for pagination, could you open the console and see if there's any errors? – Klaus Nov 14 '16 at 05:34
  • No errors in the console. As I said a refresh of the page shows the correct grid page, but only then does it show up. – Luka Nov 14 '16 at 08:28
  • Ok, my mistake. The error is in the controller. The data is actually not kept and that the reason why I see no records in the grid. i am now saving the records in a Session and use that for my $criteria, till I find out how the Controller should actually look. – Luka Nov 14 '16 at 11:48
  • I'm glad you found the problem. – Klaus Nov 14 '16 at 12:34

0 Answers0