Copied to clipboard

Flag this post as spam?

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


  • Mark Watson 118 posts 384 karma points
    Jun 21, 2018 @ 01:52
    Mark Watson
    0

    How do you sort a partial view

    I have created a partial view "Physicians" that displays a list of all active members. How do I display the members for each state. The state selection is controled by a drop down menu and displayed in the partial view by the var selectedState.

    <h3>New South Wales</h3>
    

    @Html.Partial("Physicians")

        <h3>Queensland</h3>
    

    @Html.Partial("Physicians")

  • pranjal 75 posts 188 karma points
    Jun 21, 2018 @ 13:36
    pranjal
    0

    Use Umbraco Razor Sort nodes in ascending and descending order

  • Mark Watson 118 posts 384 karma points
    Jun 21, 2018 @ 22:59
    Mark Watson
    0

    Thanks Pranjal

    How do i do that i am new to Umbraco?

  • Nathan Woulfe 447 posts 1664 karma points MVP 5x hq c-trib
    Jun 22, 2018 @ 03:23
    Nathan Woulfe
    0

    Hi Mark

    I'm guessing there's logic feeding the list of physicians back to your partial view (or living in the view itself)? From your main view, you could pass a parameter to the partial to use as a filter for the complete set of members.

    @Html.Partial("Physicians", new ViewDataDictionary({{ state = "Queensland" }}));
    

    Which would be available in the partial as

    @ViewData["state"]
    

    Another option would be Html.Action:

    @Html.Action("MyMethodName", "MyController", new { state = "Queensland" });
    

    Which can still use the same Physicians partial UI, but would move the logic into MyMethodName on MyController, where state would be passed in as a parameter of MyMethodName. From there, you return a model to the Physicians partial, and enjoy strongly-type goodness in your UI

Please Sign in or register to post replies

Write your reply to:

Draft