API Reference: DisplayOrderAttribute Class
The DisplayOrderAttribute
can be applied to content model properties. The attribute sets the display order of the property in the user interface of the back office application.
If DisplayOrderAttribute
is not specified, the property will have a display order value of 0 by default. Consecutive properties that are not decorated with the attribute (and therefore all have order 0 by default) will be ordered in the same order in which they appear on the class.
Usage
Decorate the content model class or property with the DisplayOrderAttribute
. Pass the order integer value in the attribute constructor. Negative order values are allowed. Properties are ordered from low to high order values, rendering them from top to bottom in the back office user interface, and left to right for inline properties.
Properties (including those from base classes) are first ordered by display order and then grouped into sections (if any). The property with the lowest display order from each section effectively determines the display order of the sections themselves.
Properties with the same display order value will be ordered in the same order in which they appear on the class. In case properties have the same display order as properties from a base class, the display order between those properties is undetermined.
Example
The following example demonstrates the use of the display order attribute.
[Page]
public class ContentPage: IContentType
{
[Section("Section 1")]
[DisplayOrder(1)]
public string Property1 { get; set; }
// Display order is 0 by default, and therefore this property gets ordered before the previous property.
[Section("Section 1")]
public string Property2 { get; set; }
[Section("Section 1")]
[DisplayOrder(3)]
public string Property3 { get; set; }
// Properties in section 2 have the same display order so are ordered in the same order the appear on the class.
[Section("Section 2")]
[DisplayOrder(5)]
public string Property4 { get; set; }
[Section("Section 2")]
[DisplayOrder(5)]
public string Property5 { get; set; }
}