Yii CListView pagination linking to previous result

137 Views Asked by At

I have a CListView with pagination showing all results. Everything works fine.

I have a search widget on the page that renders a partial view to replace the existing list with search results.

The first search result page loads, looks great, and even shows the correct number of results in pagination, but if I try to go to one of the next pages, items from the first list are loaded.

Does anyone know what I have to do in order to fix this? Do the search results need their own full view rendered?

Thanks you in advance.

1

There are 1 best solutions below

0
On

I was mistaken.

The pagination was not linking to the previous result, it was loading everything which the previous result also does, which is why I was mistaken.

I thought that the data provider in the controller kept track of the result set but you have to keep resending the same criteria every time. I was sending the criteria the first time and not on subsequent results so it loaded everything in absence of any constraints. I simply put the search parameters in session and then retrieved them so they could be considered on every request and it fixed the problem.

In short there is no bug, just me being new working with Yii.