How to hide/show property in all properties view based on selection of another property

Vote:
 

I need to be able to toggle a few properties on and off based on the choice made in another property of the same page. I need it to update the all properties view as soon as a change is made to that property. I have been searching for a while for a simple way to do this, but all I am finding is many old solutions that take different approaches and I am not sure even work with the latest version of Episerver. Rather than go down any of those rabbie holes, I am hoping someone has some working examples of this they can share with me. Does anyone have a working example of this that they can post here that hopefully does not require a lot of work in dojo? 

#217131
Feb 17, 2020 22:33
Vote:
 
#217134
Feb 18, 2020 7:43
Vote:
 

If you are OK with having to save the page to update what properties are shown/hidden, you can do this completely without dojo. If you make the property that decides what properties to show required and don't intend to change it's value frequently - that could work. 

Add an editor descriptor like this:

[EditorDescriptorRegistration(TargetType = typeof(string), UIHint = "hideiffoo")]
public class HidePropertyEditorDescriptor : EditorDescriptor
{
    public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
    {
        base.ModifyMetadata(metadata, attributes);

        var contentMetadata = (ContentDataMetadata)metadata;
        var ownerContent = contentMetadata.OwnerContent;

        var myPage = ownerContent as MyPageType;

        if (myPage?.Foo)
        {
            metadata.ShowForEdit = false;
        }
    }
}

Then just add [UIHint("hideiffoo")] to the property you want to hide if the property Foo is true.

Kinda quick and dirty, but I think it will work.

#217157
Edited, Feb 18, 2020 19:38
Vote:
 

The alloy plugin worked beautifully. It does it all for me. Exactly what i was looking for! Thanks guys.

#217159
Feb 18, 2020 20:45
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.