System Library Common Episerver
Search Results for

    DocFx,SystemLibrary.Common.Episerver.Properties.MessageConfig,SystemLibrary.Common.Episerver.Properties.MessageEditorDescriptor,SystemLibrary.Common.Episerver.Properties.MessageProperty,SystemLibrary.Common.Episerver.Properties.MessageController,SystemLibrary.Common.Episerver.Attributes.BoxSelectionController,SystemLibrary.Common.Episerver.Attributes.BoxSelectionFactory,SystemLibrary.Common.Episerver.Attributes.JsonEditController,SystemLibrary.Common.Episerver.Attributes.JsonEditFactory,SystemLibrary.Common.Episerver.Descriptors.HideCategoryListDescriptor,SystemLibrary.Common.Episerver.Properties.ParentLinkReferenceController,SystemLibrary.Common.Episerver.Properties.ParentLinkReferenceEditorDescriptor,SystemLibrary.Common.Episerver.Properties.ParentLinkReferenceProperty,SystemLibrary.Common.Episerver.Attributes.MultiDropdownSelectionController,SystemLibrary.Common.Episerver.Attributes.MultiDropdownSelectionFactory,SystemLibrary.Common.Episerver.Initialize.RemoveSuggestedContentTypes,SystemLibrary.Common.Episerver.Extensions.CommonEpiserverApplicationServicesOptions,SystemLibrary.Common.Episerver.Extensions.CommonEpiserverApplicationBuilderOptions,SystemLibrary.Common.Episerver.EditController,SystemLibrary.Common.Episerver.Abstract.BaseController,SystemLibrary.Common.Episerver.Abstract.BaseMultiSelectionFactory,SystemLibrary.Common.Episerver.ConnectionStringsConfig,SystemLibrary.Common.Episerver.PropertiesConfig,SystemLibrary.Common.Episerver.EditConfig,SystemLibrary.Common.Episerver.Properties.MessageConfig,SystemLibrary.Common.Episerver.FontAwesome,SystemLibrary.Common.Episerver.AppSettings.Configuration,SystemLibrary.Common.Episerver.Attributes.ParentLinkReferenceFactory,SystemLibrary.Common.Episerver.Abstract.InternalBaseController,WebApplicationInitializer
    Show / Hide Table of Contents
    NamespaceSystemLibrary.Common.Episerver.Attributes SystemLibrary.Common.Episerver.dll

    Add Json Edit attribute to a virtual string property to activate the simple Json Editor

    JsonEditAttribute

    public class JsonEditAttribute : Attribute, IDisplayMetadataProvider, IMetadataDetailsProvider

    Inheritance
    System.Object
    JsonEditAttribute
    Implements
    Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.IDisplayMetadataProvider
    Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.IMetadataDetailsProvider
    Examples
    X
    public class StartPage : PageData 
    {
        [JsonEdit(Title = "Car Selection", Type = typeof(JsonCar),  SortByPropertyName2 = nameof(JsonCar.Age))]
        public virtual string Cars { get; set; }
    }
    
    public class Car
    {
        [Required(ErrorMessage = "This shows as 'orange-red-ish' below the input field and marks the field required with a *")]
        [Display(Name = "Override 'Name' as the display name", Description = "This shows up as the placeholder of the input field")]
        public string Name { get; set; }
    
        [Display(Name = "Cars Age")]
        public int Age { get; set; } 
    
        [Display(Name = "Is it sold?")]
        public bool IsSold { get; set;}
    
        [Required]
        public DateTime Created { get; set; }
    }

    Index.cshtml

    var cars = @Model.CurrentPage.Cars.Json<List<Car>>();
    
    <Car count: @cars.Count>
    Arguments
    X

    Properties

    Optional: Set to name of a property that the Editor can sort by

    If empty, the sort button 1 is hidden inside the 'Json Editor Window'

    View Source

    public string SortByPropertyName1 { get; set; }

    X

    Sorting by 'Age' the C# property name, and the friendly name "First Name":

    public class Car
    {
        [Display(Name = "First Name")]
        public string FirstName { get; set; }
        public int Age { get; set; }
    }
    
    public class StartPage : PageData
    {
        [JsonEdit(Type = typeof(Car), SortByPropertyName1 = "First Name", SortByPropertyName2 = nameof(Car.Age))]
        public virtual string Cars { get; set ; }
    }
    X
    Property Value
    Type Description
    System.String

    Optional: Set to name of a property that the Editor can sort by

    If empty, the sort button 2 is hidden inside the 'Json Editor Window'

    View Source

    public string SortByPropertyName2 { get; set; }

    X

    Sorting by 'Age' the C# property name, and the friendly name "First Name":

    public class Car
    {
        [Display(Name = "First Name")]
        public string FirstName { get; set; }
        public int Age { get; set; }
    }
    
    public class StartPage : PageData
    {
        [JsonEdit(Type = typeof(Car), SortByPropertyName1 = "First Name", SortByPropertyName2 = nameof(Car.Age))]
        public virtual string Cars { get; set ; }
    }
    X
    Property Value
    Type Description
    System.String

    Optional: Give the Json Editor Window a simple title so its more editor friendly

    If empty, the 'Type.Name' will be used as the title of the Json Editor Window

    View Source

    public string Title { get; set; }

    X
    Property Value
    Type Description
    System.String

    The c# class that is stored as a json string, and all its properties is editable through the Json Editor

    View Source

    public Type Type { get; set; }

    X
    Property Value
    Type Description
    Type

    Methods

    View Source

    public void CreateDisplayMetadata(DisplayMetadataProviderContext context)

    X
    Methods arguments
    Type Name Description
    Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DisplayMetadataProviderContext context

    Implements

    Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.IDisplayMetadataProvider
    Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.IMetadataDetailsProvider

    Extension Methods

    TExtensions.ReactServerSideRender<T>(T, Object, String, Boolean, String, String, String, Boolean, Boolean, Boolean)

    }

    • View Source
    In This Article
    Package: nuget
    Source: github
    Website: System Library Common Episerver