November Happy Hour will be moved to Thursday December 5th.

Grouping property as tab

Vote:
 

I created a site from episerver visual studio extension mvc empty site.I need to display property in group tab.So I have tried like this:

 [Display(
            GroupName = "Count",
            Order = 4)]
        [DefaultValue(3)]
        [Required]
        public virtual int Count { get; set; }

But it doesn't show as tab, It displayed under the Content Tab.Is this proper way to do this?

#149419
May 31, 2016 17:22
Vote:
 

You should have tab Count and in that tab property Count. Did you tried creating few more properties ? With different tabs ?

#149422
May 31, 2016 17:50
Vote:
 

Hi Dil500 k,

To create a custom tab, you can use the following code:

[GroupDefinitions]
public static class MyGroupNames
{
    [Display(Order = 100)]
    public const string Count = "Count";
}

You can place it anywhere you want in your solution. On application startup, episerver will create a new tab for you (if it doesn't exist).

To move the property to Count tab, you can use the following code:

[Display(GroupName = MyGroupNames.Count)]
public virtual int MyValue { get; set; }

To set a default value for MyValue property, you shouldn't use DefaultValue attribute. Instead, you have to override SetDefaultValues method in your page type:

public override void SetDefaultValues(ContentType contentType)
{
    base.SetDefaultValues(contentType);
    MyValue = 3;
}

Your page type should look like this:

[ContentType(GUID = "DAF174A1-AB94-4BF1-A4A6-9191341A45B8")]
public class MyPage : PageData
{
    [Display(GroupName = MyGroupNames.Count)]
    public virtual int MyValue { get; set; }

    public override void SetDefaultValues(ContentType contentType)
    {
        base.SetDefaultValues(contentType);
        MyValue = 3;
    }
}

Hope this helps!

#149431
May 31, 2016 22:04
* 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.