Copied to clipboard

Flag this post as spam?

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


  • Bhudsarin C. 6 posts 86 karma points
    Sep 09, 2018 @ 07:37
    Bhudsarin C.
    0

    How to get value that was selected from nuPickers.XmlCheckBoxPicker property

    Hi,

    I woud like to get value were selected from nuPickers.XmlCheckBoxPicker property and show on patial view. Do someone has example how to get it?

    Thank you so much.

  • Alex Brown 129 posts 620 karma points
    Sep 09, 2018 @ 09:40
    Alex Brown
    1

    Assuming you're using ModelsBuilder you can do the following:

    @foreach (var checkbox in Model.Content.*YourCheckboxPropertyHere*.AsPublishedContent())
    {
        @checkbox.Name
    }
    

    The .AsPublishedContent will convert the checkboxes into an IEnumerable

  • Bhudsarin C. 6 posts 86 karma points
    Sep 10, 2018 @ 03:22
    Bhudsarin C.
    0

    Thank you so much for your reply.

  • Marc Goodson 2157 posts 14434 karma points MVP 9x c-trib
    Sep 09, 2018 @ 10:01
    Marc Goodson
    100

    Hi Bhudsarin

    It depends a little on what the source of your NuPickers Checkboxlist is...

    Have a read of the different options here:

    https://github.com/uComponents/nuPickers/wiki/Model

    But essentially if your CheckboxList source is Umbraco Content, then

    @{
        var pickedItems = Model.Content.GetPropertyValue<Picker>("myNuPickerPropertyAlias");
        <ul>
            @foreach (var item in pickedItems.AsPublishedContent())
            {
                <li>@item.Name - @item.GetPropertyValue("title")</li>
            }
        </ul>
    }
    

    making sure to add

    @using nuPickers;
    @using nuPickers.Extensions;
    

    at the top of your view...

    regards

    Marc

    Update: sorry Alex didn't see you had already replied!

  • Bhudsarin C. 6 posts 86 karma points
    Sep 10, 2018 @ 03:26
    Bhudsarin C.
    0

    Thank you so much for your help. It's good explanations including source link.

  • Alex Brown 129 posts 620 karma points
    Sep 10, 2018 @ 07:00
    Alex Brown
    0

    No worries Marc, your answer was far more detailed.

    Edit: Bhudsarin could you set Marc's reply as the solution?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies