- Add a field to the database, see the introduction to the Database Plus fields section
- In the twig of all, the type of rational keystrokes, to increase the sorting function as follows: <th> status <br/><a class= "ASC" data-id= "STATUS=ASC" > Positive order </a> | <a class= "desc" data-id= "Status=desc" > Reverse </a></th>
- Add JS to trigger this event
<script> $ (document). Ready (function () { $ ('. Asc,.desc '). CSS (' cursor ', ' pointer '). Click (function () { var param = $ (this). attr (' Data-id '), href = "{{path (' Orderrecord_all ')}}", url = href+ '? ' +param; (Window.location.href=url; }); });
Add a variable to the controller to receive the variable JS passes $status = $request->get (' status ')
- Sorting data after output
$dql . = ' ORDER by '; if ($status) { $dql . = ' O.status '. $status. ', O.createdat DESC '; } Else { $dql . = ' O.createdat DESC '; }
Add a field to the database and give a sort