嗨,我有一个带有元素列表(index.html.twig.)的表格的页面。我正在使用 KNP Paginator Bundle 对结果进行分页。现在我想在这个页面中实现某种过滤器来过滤表结果。我正在使用 AJAX 来执行此操作,因此我创建了另一个 View (grupos.html.twig),其中包含表和分页器以呈现查询结果。
这是 Controller 代码:
public function filtrarGrupoPorLetraAction(){
if ($this->getRequest()->isXmlHttpRequest()) {
$em = $this->getDoctrine()->getManager();
$letra = $this->getRequest()->get('letra');
$entities = $em->getRepository('GrupoBundle:Grupo')->filtrar($letra);
$paginator = $this->get('knp_paginator');
$pagination = $paginator->paginate(
$entities,
$this->get('request')->query->get('page', 1) /*page number*/,
25/*limit per page*/
);
return $this->render('GrupoBundle:Grupo:grupos.html.twig', compact('pagination'));
}
}
但是这段代码呈现了一个新页面,我想将结果传递给 index.html.twig 来呈现一个 div。
我怎样才能做到这一点?
最佳答案
只需将您的结果数据附加到您的 div
关于ajax - 带有 KNP Paginator Bundle 的 Symfony 2.1 ajax 过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13976687/