S
S
symnoob2020-06-16 15:24:21
symfony
symnoob, 2020-06-16 15:24:21

Symfony - Twig how to make reusable links for sorting in CRUD?

Hello everyone,

I have many different data sheets in my project. (something like Data-Grid)

Is there any good solution to create links to sort columns?

Thanks a lot, everyone

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sl0, 2020-06-16
@sl0

There is a very good and simple solution - use knp paginator. It has a separate item in the settings for setting links for sorting.

template:
        pagination: '@KnpPaginator/Pagination/twitter_bootstrap_v4_pagination.html.twig'
        sortable: '@KnpPaginator/Pagination/sortable_link.html.twig'

Then just in the template:
<th>{{ knp_pagination_sortable(pagination, 'Date', 'date') }}</th>
                <th>{{ knp_pagination_sortable(pagination, 'Name', 'name') }}</th>
                <th>{{ knp_pagination_sortable(pagination, 'Email', 'email') }}</th>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question