Copied to clipboard

Flag this post as spam?

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


  • Euge 23 posts 130 karma points
    Aug 12, 2013 @ 12:00
    Euge
    0

    Best approach for creating cascading selectlist

    HI

    What would be the best approach for creating cascading dropdowns Razor in Umbraco v 4.9.1 ?

    Essentially I'll have a selectlist that lists a set of nodes which filters a 2nd list of subnodes.

    So something like

        <select id="selectList" name="selectList">
             <option value="0">All Widgets</option>
            @foreach (var item in Model.AncestorOrSelf().Descendants("widgets").Where("visible").OrderBy("Name"))
            {
                <option value="@item.title">@item.title</option>
            }
        </select>

     

        then 2nd select list filtered by whatever is select in above selectlist

     

    Thanks

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Aug 13, 2013 @ 15:06
    Jeavon Leopold
    0

    Hi Eugene,

    I would approach this by creating a /base method which would have 1 parameter which would be the nodeId of the selected node, the method would then return data of the subnodes (id and name).

    Then I would use the Ajax jQuery method to make the request and populate the second select on the change event of the first select.

    There is a sample which might help you get started with this approach here albeit returning member data instead of content.

    FYI, if you were using Umbraco v6.1, you could use UmbracoApi which makes this a fair bit easier...

    Hope that's all helpful?

    Jeavon

  • Balvvant 5 posts 25 karma points
    Feb 28, 2014 @ 18:03
    Balvvant
    0

    Hi,

    I have gone through this control and the trainig video. But I am not able to find a way to fit my requirement in this.

    I have following structure... enter image description here

    I need to create cascading dropdown in such a way that the first dropdown shows all the L1 level entries. When user select any item in this dropdown then it will fill the second dropdown with all L2 items under selected L1 level value. When user selects the L2 level value then the third dropdown should show be filled with all the values in the L3 level under the selected L2 level values. When user publish the data it should able to save it and display back when selected the same node. How we can achieve this.

    Appreciate your help. Thanks a lot.

Please Sign in or register to post replies

Write your reply to:

Draft