dongsha7215 2014-05-19 15: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 :

public function searchAction(Request $request)
    {

        $em = $this->getDoctrine()->getManager();
        $form =  $this->createSearchForm();
        $form->handleRequest($request);
        //initialisation de l'objet paginator
        $paginator  = $this->get('knp_paginator');

            $data=$form->getData();
            $entities = $em->getRepository('EnsDataBundle:Data')->findterm($data['searchterm']);

            $pagination = $paginator->paginate($entities, $this->get('request')->query->get('page', 1),3);


            return $this->render('EnsDataBundle:Data:index.html.twig', array(
                'entities' => $pagination,
                'form' => $form->createView(),
            ));
    }

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 16: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 !

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

报告相同问题?

悬赏问题

  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动