Problem in showing custom property value in epi cms

 

Hi,

I am referred below URL and created one custom property in epi page. But added values are displaying [object object] in epi all properties view.

https://world.episerver.com/blogs/Per-Magne-Skuseth/Dates/2015/11/trying-out-propertylistt/

public class VinDecodeMakeModelMapping
{
[Display(Name = "Make")]
public string Make { get; set; }

[Display(Name = "Models Mappings")]
public IEnumerable Models { get; set; }
}

-----------

[PropertyDefinitionTypePlugIn]
public class VinDecodeMakeModelMappingsListBase : PropertyListBase
{
}

---------

public class PropertyListBase : PropertyList
{
private readonly IObjectSerializer objectSerializer;

private Injected objectSerializerFactory;

public PropertyListBase()
{
this.objectSerializer = this.objectSerializerFactory.Service.GetSerializer("application/json");
}

protected override T ParseItem(string value)
{
return this.objectSerializer.Deserialize(value);
}

public override PropertyData ParseToObject(string value)
{
this.ParseToSelf(value);

return this;
}
}

--------

I created a property on my page

  [EditorDescriptor(EditorDescriptorType = typeof(CollectionEditorDescriptor))]
public virtual IList VinDecodeMakeModel { get; set; }

------

check link my epi all property page

https://drive.google.com/open?id=1G9PnDCDJs3arlPMkRlZyXuV2vR7VuEFV

Please reply asap,

Advance thanks

#193965 Edited, Jun 08, 2018 15:35
  • Johan Kronberg
    Member since: 2005
     
    #193975 Jun 08, 2018 23:45
  •  

    Thank you johan,

    But my problem not resolved. I tried below thing also but it throws an diji error.

    [Display(Name = "Models Mappings")]
    [JsonProperty]
    [JsonConverter(typeof(IList<KeyValueItem>))]
    public IEnumerable<KeyValueItem> Models { get; set; }

    In that link finally opened with an answer the bug was fixed and released(epi 11..ver) but My epi cms version is 10.3.1. Not possible to upgrade my project(it have many processes getting approved).

    Can you pls give some answer to handle by a custom dojo editor.

    Advance thank you,

    #193981 Jun 10, 2018 12:18
  •  

    Thank you johan,

    But my problem not resolved. I tried below thing.But not works anything i am missing pls notify me

    [Display(Name = "Models Mappings")]
    [JsonProperty]
    [JsonConverter(typeof(ListConvert<KeyValueItem>))]
    public IEnumerable<KeyValueItem> Models { get; set; }

    public class ListConvert<T> : JsonConverter
    {
    public override bool CanConvert(Type objectType)
    {
    return objectType == typeof(List<T>);
    }

    public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
    {
    JToken token = JToken.Load(reader);
    if (token.Type == JTokenType.Array)
    {
    return token.ToObject<List<T>>();
    }
    return new List<T> { token.ToObject<T>() };
    }

    public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
    {
    List<T> list = (List<T>)value;
    if (list.Count == 1)
    {
    value = list[0];
    }
    serializer.Serialize(writer, value);
    }

    public override bool CanWrite
    {
    get { return true; }
    }
    }

    In that link finally opened with an answer the bug was fixed and released(epi 11..ver) but My epi cms version is 10.3.1. Not possible to upgrade my project(it have many processes getting approved).

    can you pls give some answer to handle by a custom dojo editor or by above code.

    Advance thank you,

    #193982 Edited, Jun 10, 2018 12:49
  •  

    I don't no what I missed but code dint works. I getting the list of values in page data but in the UI it not showing edit also not showing already existing values. Please reply asap.

    Advance thanks,

    #193983 Jun 10, 2018 16:11
  • Antti Alasvuo
    Member since: 2010
     

    Hi Karthikeyan,

    As Johan already linked the forum post where similiar issue was troubleshooted but a newer release than yours, I would say that you are out of luck with your version of CMS.

    BETA was lifted from PropertyList<T> in update 189 (EPiServer.CMS.Core 11.1.0) and as you can see in the blog post others were having issues with the propertylist as it was BETA (and the thread started by Greg points out that the object Object issue was solved in 208 update).

    You could try the StringListEditor (Business.EditorDescriptors.StringListEditorDescriptor) from Alloy I mention in the thread started by Greg - it might work in your case (so you have models property as a textarea and separate each model to its own line).

    #194035 Jun 11, 2018 19:32