Question

We have a need to create a custom property for a project we are working on. We are creating a shared block that is going to show a graph.

The editor can set title and type of (chart, donut etc.) the graph, these are ordinary string properties.Next the editor need to create data for each part of the chart, example is that the editor is going to create three columns holidng data for a Basic Column Chart.

Each part of the column chart is holding three values and we manage this properies in a class called GraphPartint value; string color; string description;What we want to create is a custom property that the user easily can create as many as they like to the block graph. Something similiar as the LinkItemCollection property works.What are the best practise and how should we implement this?

All suggestions and tips/guides are welcome.Example of code below

[ContentType(
    DisplayName = "Graf",
    Description = "Block med graf",
    AvailableInEditMode = true)]
[ImageUrl("~/Content/icons/block-type-graf-stapel.jpg")]
public class GraphBlock : BlockData
{
    [Display(
       Name = "Diagramtyp",
       Description = "Välj vilken diagramtyp som ",
       GroupName = SystemTabNames.Content,
       Order = 0)]
    [UIHint(SiteUIHints.GraphTypes)]
    public virtual string Typ { get; set; }

    [Display(
        Name = "Title",
        Description = "Beskrivande titel kan anges",
        GroupName = SystemTabNames.Content,
        Order = 1)]
    public virtual string MainTitle { get; set; }

    [Display(
        Name = "Diagrambitar",
        Description = "För varje bit av diagram måste en diagrambit med tre värden anges.",
        GroupName = SystemTabNames.Content,
        Order = 2)]
    public virtual IEnumerable<GraphParts> GraphParts { get; set; }
}

public class GraphPart
{
    public int Value { get; set; }
    public string Title { get; set; }
    public string Color { get; set; }
}
Was it helpful?

Solution

Followed this tutorial to find a solution for my need:http://epideveloper.blogspot.se/2013/10/episerver-7-custom-property-combined.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top