Add a field to the database and give a sort

Source: Internet
Author: User

    1. Add a field to the database, see the introduction to the Database Plus fields section
    2. 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>
    3. 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;        });    });
    4. Add a variable to the controller to receive the variable JS passes $status = $request->get (' status ')

    5. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.