Copied to clipboard

Flag this post as spam?

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


  • mrquan1506 9 posts 91 karma points
    Jun 28, 2018 @ 09:53
    mrquan1506
    0

    Add prevalue in checkbox list from another data source ?

    Hi all,

    I'm quite new to Umbraco. I dont know how to explain clearly the problem I face, but I will use images to demonstrate it.

    For example, I have a content named Company Management which has a company list property. This list is created based on nested content type, so the list is able to add or remove items. (I'm considering using Archetype instead) Pic1

    Now all I want to do is put all the items in this list into prevalue of a permission checkbox property in another content page. It 'll be something like this.

    enter image description here

    So, whenever I update the list on Company Management page, the list items in permission check box also updated.

    Thus, can you give me some advices or approaches for this situation. I searched a lot but nothing good comes up. Maybe I used wrong keywords.

  • mrquan1506 9 posts 91 karma points
    Jun 29, 2018 @ 03:00
    mrquan1506
    0

    I think this is the quite normal problem, hope someone can see and help me. Thank all !

  • Hendy Racher 861 posts 3844 karma points MVP 2x admin c-trib
    Jun 29, 2018 @ 08:09
    Hendy Racher
    102

    Hi there, it sounds like the DotNet CheckBox Picker in nuPickers package could help out here.

    using System.Collections.Generic;
    using System.Linq;
    using nuPickers.Shared.DotNetDataSource;
    
    public class CompaniesDotNetDataSource : IDotNetDataSource
    {
        IEnumerable<KeyValuePair<string, string>> IDotNetDataSource.GetEditorDataItems(int contextId)
        {
            var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
    
            var companyManagement = umbracoHelper.TypedContentSingleAtXPath("//companyManagementDocTypeAlias[@isDoc]");
    
            // if using models builder this should be IEnumerable<IPublishedContent>
            var companies = companyManagement.CompanyList;
    
            return companies.ToDictionary(x => x.Id.ToString(), x => x.Name);
        }
    }
    

    HTH, Hendy

  • mrquan1506 9 posts 91 karma points
    Jul 02, 2018 @ 06:42
    mrquan1506
    1

    Thank you so much Hendy Racheradmin,

    I know what to do next. Thank you again !

  • Oliver 6 posts 75 karma points
    Dec 05, 2019 @ 13:53
    Oliver
    0

    Hi Hendy.

    How are you setting this up? Where are you placing your CompaniesDotNetDataSource.cs ? What are you refering to as Assembley in nupicker setup? I'm runing Umbraco 7.15.3, nuPickers 1.7.1 and don“t have a App_Code folder.

    /Oliver

  • 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