Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

Property list not being able to save/publish

Vote:
 

CMS 11.14.2

Ive implemented an IList<MenuItem> but it is not triggering the "Save/publish" button on change/add, what am I missing? 

Ive implemented the necessary items i think: 

[Display(Order = 340, GroupName = TabNames.Menu)]
[EditorDescriptor(EditorDescriptorType = typeof(CollectionEditorDescriptor<MenuItem>))]
public virtual IList<MenuItem> TopBannerMenu { get; set; }

[PropertyDefinitionTypePlugIn]
public class MenuItemListProperty : PropertyListBase<MenuItem>
{

}

public class PropertyListBase<T> : PropertyList<T>
{
        private readonly IObjectSerializer _objectSerializer;
        private Injected<ObjectSerializerFactory> _objectSerializerFactory;

        public PropertyListBase()
        {
            _objectSerializer = _objectSerializerFactory.Service.GetSerializer("application/json");
        }

        protected override T ParseItem(string value)
        {
            return _objectSerializer.Deserialize<T>(value);
        }
}

No javascript error in console, other property lists in solution are working. 

#227300
Edited, Sep 01, 2020 8:13
Vote:
 

Have you tried without using a custom PropertyListBase<>? Shouldn't need that anymore. Probably some issue with json serialization...

[PropertyDefinitionTypePlugIn]
public class MenuItemListProperty : PropertyList<MenuItem> { }

What does MenuItem contain? Any suspect url properties?

#227301
Sep 01, 2020 8:23
Vote:
 

Hej Daniel, 

hmm without it i get 

Type 'System.Collections.Generic.IList`1[[Shared.MenuItem, x.Site, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null]]' could not be mapped to a PropertyDefinitionType

    public class MenuItem
    {
        public string Title { get; set; }

        public bool CssBold { get; set; }
        public bool CssCampaign { get; set; }
    }

This is locally for now. I have tested with Url and removed it for test. Ive seen solution with UrlConverter if I were to use Url. 

#227302
Sep 01, 2020 8:48
Vote:
 

Hi, Daniel is right about the base class.

I just copied your code into an Alloy site, and made some small adjustments.

My example menu class:

public class MenuItem
{
    public string Title { get; set; }
    public string Url { get; set; }
}

The property definition:

[PropertyDefinitionTypePlugIn(
    DisplayName = "Menu list property",
    GUID = "28B811BE-9551-4F73-A86E-584044432B66")]
[Serializable]
public class MenuItemListProperty : PropertyList<MenuItem>
{

}

I like adding a name and guid to my property definitions. Why: https://www.gulla.net/episerver-and-renaming-a-custom-property/
I also added the Serializable-attribute.

Then add a property to ArticlePage:

[Display(Order = 340, GroupName = "Menu")]
[EditorDescriptor(EditorDescriptorType = typeof(CollectionEditorDescriptor<MenuItem>))]
public virtual IList<MenuItem> TopBannerMenu { get; set; }

It worked for me in an Alloy site running 11.18.0 (I know that version were delisted).

If it still does not work, I would enter admin mide, click «Config», «Edit custom property types», then delete your property definition and restart the site.

#227372
Edited, Sep 02, 2020 11:45
Vote:
 

thx Thomas, I changed to

 MenuItemListProperty : PropertyList<MenuItem>

and removed the property, restarted, and i works!

Thanks ;)

#227376
Sep 02, 2020 12:47
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.