Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • steschu 88 posts 489 karma points
    Oct 07, 2018 @ 21:20
    steschu
    0

    Sorting and Filtering tables in view template

    Hi,

    In the view template of my parent page I want to display all names and some basic data of the child pages as a table. And I want to sort that table and filter it.

    The only way I see is simply add manual links in the table headers like (<a href="?sortfield=XYZ">XYZ</a>) and process the parameter in the template code before getting and displaying the data. Is that right? Is there a best practice (piece of code, helper class, etc.) to build the full url with parameters? There might be an arbitray number of other parameters like filter or paging info that also have to be in the generated URL.

    I found that example on asp.net, but as I understand the umbraco architecture it is not possible to use Html.ActionLink unless you use Custom controllers (Hijacking Umbraco Routes)? If anybody has a better solution, please tell me.

    Thanks, Stephan

  • Lars Heesakkers 38 posts 194 karma points
    Oct 08, 2018 @ 13:45
    Lars Heesakkers
    0

    I found that example on asp.net, but as I understand the umbraco architecture it is not possible to use Html.ActionLink unless you use Custom controllers (Hijacking Umbraco Routes)?

    So why don't you do that? You can just create a (custom) SurfaceController which you can use right?

  • steschu 88 posts 489 karma points
    Oct 08, 2018 @ 14:25
    steschu
    0

    Why I don't do that? Because filtering, sorting and paging seems to me such a common and frequent scenario that I doubted the hijacking is the right way to do it... in the documentation hijacking routes is more described as a last resort way to solve things?

  • Lars Heesakkers 38 posts 194 karma points
    Oct 08, 2018 @ 14:27
    Lars Heesakkers
    0

    Route hijacking is quite common, at least from my experience. What i would do in you situation is just create the table from the Children-data en use JavaScript to handle sorting and filtering. But that might be quite hard with an arbitrary number of filters

  • steschu 88 posts 489 karma points
    May 16, 2019 @ 13:21
    steschu
    100

    This posting is some months old. Meanwhile I've gained more experience in Umbraco. I would say that Child-Actions is the solution, or generally passing the parameters via GET or POST in a form. Hijacking Routes is also possible, but I wouldn't prefer it.

Please Sign in or register to post replies

Write your reply to:

Draft