Copied to clipboard

Flag this post as spam?

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


  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Oct 19, 2016 @ 17:39
    Lee Kelleher
    0

    Show Label on Grid property

    Is it possible to show the property label for the Grid?

    I know that typically the Grid is intended to be full-width, but it looks a bit odd in a scenario that I'm currently working on.

    Grid editor without property name/description

    Any advice on how it might be possible to display the property's name & description?

    Even if it's considered hacky C# code ;-)

    Thanks,
    - Lee

  • Ian 178 posts 752 karma points
    Oct 19, 2016 @ 23:22
    Ian
    104

    Don't know how hacky you feel this is but it works.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Umbraco.Core;
    using Umbraco.Web.Editors;
    using Umbraco.Web.Models.ContentEditing;
    
    namespace UmbracoTest735.Classes
    {
        public class ContentModelModifier : ApplicationEventHandler
        {
            protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
            {
                EditorModelEventManager.SendingContentModel += (sender, e) =>
                {
                    IEnumerable<ContentPropertyDisplay> gridDisplayProperties = e.Model.Properties.Where(x=>x.Editor == "Umbraco.Grid");
                    foreach(ContentPropertyDisplay gridDisplayProperty in gridDisplayProperties)
                    {
                        gridDisplayProperty.HideLabel = false;
                    }
                };
            }
        }
    }
    
  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Oct 20, 2016 @ 10:12
    Lee Kelleher
    0

    ooooh, I did not know about EditorModelEventManager events. I shall give that a try.

    Thank you Ian! (I'm cool with this type of hackiness!)

    Cheers,
    - Lee

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Oct 20, 2016 @ 10:32
    Lee Kelleher
    0

    Thanks Ian, this worked a treat! #h5yr

    Cheers,
    - Lee

  • Ian 178 posts 752 karma points
    Oct 20, 2016 @ 19:33
    Ian
    0

    Yes I think its an event which has all sorts of uses. Glad it helped

Please Sign in or register to post replies

Write your reply to:

Draft