Sort by date

Asked

Viewed 498 times

0

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

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

  • Take a look if this helps you: http://tablesorter.com/docs/

  • If you have already sent the data to the client, it should be sent already ordered or provide some form of sorting with Javascript or jQuery. If you didn’t send them, you need to sort with PHP or directly with SQL. Describe your problem better.

  • The thing is, we imagine a table with various interventions on a machine, what I want is to sort these interventions by date, from today down.

  • It is an equal table there is in the link below in the Demo that I intended, but instead of having to click in the fields to sort, the table is already sorted by date. http://tablesorter.com/docs/

  • You can simply pull the data from Data, and send it to the already ordered client

  • How can I do that?

  • @Catarinasilvestre post as you are currently searching for this data, and we propose a change upon this.

Show 2 more comments

1 answer

1

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

There are several ways to do it, you can do the query directly in 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: http://symfony.com/doc/current/book/doctrine.html

Browser other questions tagged

You are not signed in. Login or sign up in order to post.