开发者

Symfony: paginate a filtered list

开发者 https://www.devze.com 2023-04-06 17:09 出处:网络
Hi i have the following code: public function executeFilter(sfWebRequest $request) { $c = new Criteria();

Hi i have the following code:

public function executeFilter(sfWebRequest $request) {
    $c = new Criteria();
    $c->add(NomenclatoreCodicePeer::LIST_CODE, $request->getParameter('list_code'), Criteria::LIKE);
    $pager = new sfPropelPager('NomenclatoreCodice', sfConfig::get('app_max_jobs_on_category'));
    $pager->setCriteria($c);
    $pager->setPage($this->getRequestParameter('page', 1));
    $pager-开发者_JAVA技巧>init();
    $this->pager = $pager;
}

It works fine, but when i press "next page" button it loose the filtered items and page as if filter had not been set. how can i fix it?


You should debug the queries to see if they are correct on each page.

My first guess would be that the list_code parameter is not set on subsequent requests. Is the list_code parameter also passed to the url for the second page? And is the filter action called on the second page? Or just your default list(?) action?

0

精彩评论

暂无评论...
验证码 换一张
取 消