Copied to clipboard

Flag this post as spam?

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


  • Rohan 105 posts 162 karma points
    Jan 20, 2018 @ 09:37
    Rohan
    0

    how to show selected content picker name or it's property name in Content node list view for child items

    Hi

    This is Rohan Dave.

    I am showing List view in Umbraco backoffice Content for some specific Content node.

    Ex. 1) I have "Team" as root document type with "List view enable" for child items. Underneath it i have "Team Details" documnet type which is child document with "Team Name" as property. From "Content -> Team" and i have added 3 teams in it and showing ok in List view.

    2) Now i have another document type "Team Leaders" is root type with "List View enable" for child items. Underneath it i have "Team Leader Details" document type which is child document with "Team Leader Name" as textControl property and "Team" as Content Picker. So i can select team against each leader. Up to this all working ok.

    Now for "Team Leaders" listview i need to show "Team" name as well but right now it's showing blank or "umb://document" etc. I want to show Team name in list view. See the attached screen shot for reference.

    Any help would be appreciated. !

    thanks in advance ! rohanenter image description here

  • Jim 15 posts 58 karma points
    Feb 13, 2018 @ 22:12
    Jim
    0

    @Rohan, did you have any luck with this? I have the exact same need.

  • Rohan 105 posts 162 karma points
    Feb 15, 2018 @ 05:37
    Rohan
    0

    Hi Jim

    No i didn't find the way.

    If you come across any solution then please share with me.

    Thanks, Rohan

  • Marcio Goularte 250 posts 801 karma points
    Feb 15, 2018 @ 19:44
    Marcio Goularte
    0

    you can do this in the contentservice saving.

    https://our.umbraco.org/Documentation/Reference/Events/ContentService-Events

      using Umbraco.Core;
        using Umbraco.Core.Services;
        using Umbraco.Core.Models;
        using Umbraco.Core.Events;
    
    
        namespace Mynamespace
        {
            public class UmbracoEvents : ApplicationEventHandler
            {
    
                protected override void ApplicationStarted(UmbracoApplicationBase umbraco, ApplicationContext context)
                {
    
                    ContentService.Saving += Saving;
    
                }
    
                private void Saving(IContentService sender, SaveEventArgs<IContent> e)
                {
                    foreach (var entity in e.SavedEntities)
                    {
                        if (entity.ContentType.Alias == "myAlias")
                        {
                            Udi id = entity.GetValue<Udi>("picker");
    
                            var guidUdi = id as GuidUdi;
                            if (guidUdi != null)
                            {
                                var content = sender.GetById(guidUdi.Guid);
    
                                if (content != null)
                                    entity.SetValue("teamName", content.Name);
                            }
    
    
                        }
                    }
                }
            }
        }
    
  • Rohan 105 posts 162 karma points
    Feb 16, 2018 @ 05:44
    Rohan
    0

    Hi

    thanks for information.

    i will check with the way you mentioned.

    thanks,

    rohan

  • Marcio Goularte 250 posts 801 karma points
    Feb 16, 2018 @ 13:15
    Marcio Goularte
    0

    I forgot to mention. This teamName property is a label. use it in the listview. Only problem with using this approach and when the team name is updated. you would also need to update the column.

    UPDATE

    An alternative is to make your own listview

    https://24days.in/umbraco-cms/2016/custom-list-view-layouts/

  • Jim 15 posts 58 karma points
    Mar 01, 2018 @ 20:13
    Jim
    0

    Thanks Marcio - Sorry for the late reply.

    I've implemented a custom list view, but I don't see a way to get the name of the content item though. How can that be done?

  • Marcio Goularte 250 posts 801 karma points
    Mar 02, 2018 @ 01:40
    Marcio Goularte
    0

    Hi,

    Create a new property with the name "Team Name" and alias "teamName" with data type Label. Add this column in the listview. Every time you save content, the saving method will add the name of the content picker

Please Sign in or register to post replies

Write your reply to:

Draft