Episerver在编辑模式下在网格中自定义复杂数据类型

时间:2016-08-30 12:07:27

标签: episerver

我目前正在研究episerver 9 cms。

我的页面/块如下:

    public class  MenuBlock : SiteBlockData
    {

        [Display(
            Name = "Menu title",
            Description = "* Required",
            GroupName = SystemTabNames.Content,
            Order = 1)]
        public virtual string MenuTitle { get; set; }


        [Display(
          Name = "Section",
          Description = "Add menu sections",
          GroupName = SystemTabNames.Content,
          Order = 3)]
        [EditorDescriptor(EditorDescriptorType = typeof(CollectionEditorDescriptor<SectionBlock>))]
        public virtual IList<SectionBlock> Section { get; set; }

  }

public class SectionBlock
    {
        [Display(
            Name = "Section name",
            Description = "Select the Menu Image",
            GroupName = SystemTabNames.Content,
            Order = 1)]
        public virtual string SectionName { get; set; }

        [Display(
          Name = "Dishes",
          Description = "Dishes",
          GroupName = SystemTabNames.Content,
          Order = 2)]
        [EditorDescriptor(EditorDescriptorType = typeof(CollectionEditorDescriptor<DishBlock>))]
        public virtual IList<DishBlock> Dishes { get; set; }
    }

public class DishBlock
    {
        [Required(ErrorMessage = "Dish name is required")]
        [Display(Name = "Dish name",
            Description = "* Required",
            GroupName = SystemTabNames.Content,
            Order = 1)]
        public virtual string DishName { get; set; }

        [Display(
            Name = "Dish description",
            Description = "",
            GroupName = SystemTabNames.Content,
            Order = 2)]
        [UIHint(UIHint.Textarea)]
        public virtual string DishDescription { get; set; }

        [Display(
            Name = "Price",
            Description = "",
            GroupName = SystemTabNames.Content,
            Order = 4)]

        public virtual double Price { get; set; }

    }

现在在CMS中,编辑模式,它呈现为 enter image description here

如您所见,Dishes呈现为[object object]而不是dishName。

有谁能建议我如何实现这个目标?

感谢。

2 个答案:

答案 0 :(得分:1)

您可以创建自己的继承CollectionEditor的Dojo小部件,并自定义项目的呈现方式。

然后,您可以使用EditorDescriptor属性为适用的PropertyList属性指定自定义编辑器。

答案 1 :(得分:0)

您好@TedNyberg - 您是否对 PropertyList 的开发有任何见解?如果他们打算以自定义方式呈现属性而无需使用 dojo -WAY?一个简单的集合 - ToString-thingy-UIHint:ish 会很好......;)