Hi, I have page with a table with a list of elements (index.html.twig.). I'm using KNP Paginator Bundle to paginate the result. Now I want to implement some kind of filters in this page to filter the table result. I'm using AJAX to do this, so I create another view (grupos.html.twig) with the table and the paginator inside to render the result of the query. Here is the controller code:
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'));
}
}
but this code render a new page and I want to pass the result to index.html.twig to render a div.
How can I do this?