Sort by date

0

Look, is it possible to sort a table by date in javascript, symfony2 or jquery?

I have a table with several data and records and I would like to sort the records by date.

    
asked by anonymous 09.02.2015 / 17:30

1 answer

1

Using symfony2 you can already bring the data ordered in the query.

There are several ways to do this, you can query directly on the Controller or create an EntityRepository

For example in the controller:

$em = $repository = $this->getDoctrine()->getRepository('SeuBundle:Post');

//voce pode filtrar por algum campo
$dados = $em->findBy(array('tipo'=>'AB'), array('data'=>'DESC')); //ou ASC

//ou você pode trazer todos os resultados somente ordenando
$dados = $em->findBy(array(), array('data'=>'DESC'));

Source: link

    
11.02.2015 / 11:42