Clistview Pagination Only Shows First Page

I have a CListview widget with a dataProvider object assigned to it that uses pagination but only the first page shows up. I have buttons that link to all the other pages, but when I click on "Next >" the subsequent pages are have 0 records and the pagination buttons disappear.

My code is a little too complicated to post here to look over so I am just asking if anyone knows of common causes for only one page to be displayed.

Has anyone run into this problem before?

Hi jhonka

Did You enable an Ajax mechanism ?

Did you check if something wrong on request with firebug?

Also check the application.log in protected/runtime folder

  1. Ajax is working, a successful call is made to the server and a response received, the response just doesn’t have nay information in it.

  2. No javascript errors are occurring.

  3. The application log doesn’t have anything related to my requests.

I know this is a very vague post, so it is hard to get specific answers. As I said before, my code is too complicated to post everything related to this data provider, but here is the code to create the widget, am I missing something obvious?

I have also double checked and the dataProvider object has the correct number of records in it and the ‘count’ property is also being set correctly.




    <?php   $this->widget('zii.widgets.CListView', array(

            'dataProvider'=>$dataProvider,

            'itemView'=>'_sqlView',

            'template'=>"{pager}\n{items}\n{pager}",

            'viewData'=>array('display_stat'=>false),

            'enablePagination'=>true,

    ));?>



It sounds like it’s an error in your code to return the data provider.

It looks to me that it’s working fine when the page is 0, and it’s working without error but returning no record when the page is not 0.

You should log the generated SQLs and check them.

I double checked the query, and the SQL returns the correct number of records. In fact the pagination controls the correct number of pages for the number of results that should be shown, but when I click on the "next" button, the entire widget disappears.

What if manually setting the ‘id’ property?




    <?php   $this->widget('zii.widgets.CListView', array(

+           'id'=>'some-unique-id-string',

            'dataProvider'=>$dataProvider,

            'itemView'=>'_sqlView',

            'template'=>"{pager}\n{items}\n{pager}",

            'viewData'=>array('display_stat'=>false),

            'enablePagination'=>true,

    ));?>



After extensive effort and many days, I finally figured out what the problem was. The code to generate my dataprovider and the widget were flawless, but the problem was in the controller itself. I didn’t think things through clearly when I designed the controller’s actions.

The CListView to be displayed was the result of a search being run from another page. When a user arrived on the page to display the widget, he had to make a POST request. When the user clicked the “next” button to view pagination, the widget would make an AJAX GET request to the same URL. The controller’s action was programmed in such a way that it would not accept GET requests and would return no data which would make the widget disappear entirely in the user’s window. Once I realized what the problem was, fixing it was trivial.

Thanks for your help in trying to solve the problem. I know I asked a very generic question so it was hard to address, but I really appreciate the attempts.