dongsha7215 2014-05-19 07:51
浏览 57
已采纳

Knp Paginator捆绑和过滤选项问题

im using knp Paginator bundle in a page that contains a list of records and in the same page exist a search box that can give the option to search over the list of records. after i give filter term and i hit the search button the list is dislayed well in the page, but when the list exeeds the limit number for every page and i hit for example the page 2 button of knp bundle paginator it loads me all the records , it doesn't remember the term i entered.

you will find my method action used for filtering :

  1. public function searchAction(Request $request)
  2. {
  3. $em = $this->getDoctrine()->getManager();
  4. $form = $this->createSearchForm();
  5. $form->handleRequest($request);
  6. //initialisation de l'objet paginator
  7. $paginator = $this->get('knp_paginator');
  8. $data=$form->getData();
  9. $entities = $em->getRepository('EnsDataBundle:Data')->findterm($data['searchterm']);
  10. $pagination = $paginator->paginate($entities, $this->get('request')->query->get('page', 1),3);
  11. return $this->render('EnsDataBundle:Data:index.html.twig', array(
  12. 'entities' => $pagination,
  13. 'form' => $form->createView(),
  14. ));
  15. }

the method above works very well without knp paginator bundle,so the problem is how i can make knp paginator bundle use the same search term ($data['searchterm']) on multiple pages

  • 写回答

1条回答 默认 最新

  • dqnk57224 2014-05-19 08:03
    关注

    One solution is to use a GET form, not a POST form.

    If you use GET, the parameters are in the url, so the parameters are on the link for next page !

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部