Attributes

    Controls visibility of a column or form field.

    It is also possible to hide a field by passing false as its value, but [Hidden] attribute is recommended.

    • User might still show the column by using the column picker if any.

    Hidden Attribute

    namespace: Serenity.ComponentModel, assembly: Serenity.Core

    Hides a column or form field.

    This is just a subclass of VisibleAttribute with false value.

    1. {
    2. [Hidden]
    3. public string HiddenColumn { get; set; }
    4. }
    • User might still show the column by using the column picker if any.

    HideOnInsert Attribute

    namespace: Serenity.ComponentModel, assembly: Serenity.Core

    Controls whether a field is visible on new record mode.

    • This only works with forms, not columns.
    1. public class SomeColumns
    2. {
    3. [HideOnInsert]
    4. public string HideMeOnInsert { get; set; }
    5. [HideOnInsert(false)]
    6. public string DontHideMeOnInsert { get; set; }
    7. }

    HideOnUpdate Attribute

    namespace: Serenity.ComponentModel, assembly: Serenity.Core

    Controls whether a field is visible on edit record mode.

    • This only works with forms, not columns.
    1. public class SomeColumns
    2. {
    3. [HideOnUpdate]
    4. public string HideMeOnUpdate { get; set; }
    5. [HideOnUpdate(false)]
    6. public string DontHideMeOnUpdate { get; set; }

    Insertable Attribute

    namespace: Serenity.ComponentModel, assembly: Serenity.Core

    Controls if a property is editable in new record mode.

    • When used on row fields, turns on or off the Insertable flag.

    • It has no effect on columns

    namespace: Serenity.ComponentModel, assembly: Serenity.Core

    Controls if a property is editable in edit record mode.

    • When used on row fields, turns on or off the Updatable flag.

    • It has no effect on columns

    1. public class SomeForm
    2. {
    3. [Updatable(false)]
    4. public string ReadOnlyOnUpdate { get; set; }
    5. }

    DisplayName Attribute

    Determines default title for grid columns or form fields.

    1. {
    2. [DisplayName("Title for Some Field")]
    3. public string SomeField { get; set; }
    4. }
    • DisplayName attribute cannot be used on Enum members, so you have to use
      Description attribute

    This is not a Serenity attribute, it resides in .NET System assembly.

    Description Attribute

    namespace: System.ComponentModel, assembly: System

    Determines default title for enum members.

    1. public class SomeEnum
    2. {
    3. [Description("Title for Value 1")]
    4. Value1 = 1,
    5. [Description("Value 2")]
    6. Value2 = 2
    7. }
    • Titles set with this attribute is considered to be in invariant language.

    This is not a Serenity attribute, it resides in .NET System assembly.

    DisplayFormat Attribute

    namespace: Serenity.ComponentModel, assembly: Serenity.Core

    Sets the display format for a column.

    • This has no effect on editors! It is only for Display, NOT Editing. For editing, you have to change culture in web.config (not UI culture).

    • Display format strings are specific to column data and formatter type.

    • If column is a Date or DateTime column, its default formatter accepts custom DateTime format strings like dd/MM/yyyy.

    • We don’t suggest setting DisplayFormat for dates explicitly, use culture setting (not UI culture) in web.config unless a column has to display date/time in a different order than the default.

    • You may also use following standard format strings:

      • “d”: dd/MM/yyyy where DMY order changes based on current culture.
      • “g”: dd/MM/yyyy HH:mm where DMY order changes based on current culture.
      • “G”: dd/MM/yyyy HHss where DMY order changes based on current culture.
      • “s”: yyydd-MM-ddTHH:mm:ss ISO sortable date time format.
      • “u”: yyydd-MM-ddTHHss.fffZ ISO 8601 UTC.
    • If column is an integer, double or decimal it accepts .NET custom numeric format strings.

    Placeholder Attribute

    namespace: Serenity.ComponentModel, assembly: Serenity.Core

    Sets a placeholder for a form field.

    • Placeholder is shown inside the editor with gray color when editor value is empty.
    • Only basic input based editors and Select2 supports this. It is ignored by other editor types like Checkbox, Grid, FileUploadEditor etc.
    1. public class SomeForm
    2. [Placeholder("Show this inside the editor when it is empty")]
    3. public string FieldWithPlaceHolder { get; set; }
    4. }

    Sets a hint for a form field.

    • Hint is shown when field label is hovered.

    • This has no effect on columns.

    1. public class SomeForm
    2. {
    3. public string FieldWithHint { get; set; }
    4. }

    CssClass Attribute

    namespace: Serenity.ComponentModel, assembly: Serenity.Core

    Sets CSS class for grid columns and form fields.

    • For columns, it sets cssClass property of SlickColumn, which adds this class to slick cells for all rows.

    • Slick column headers are not affected by this attribute, use [HeaderCssClass] for that.

    1. public class SomeForm
    2. {
    3. [CssClass("extra-class")]
    4. public string FieldWithExtraClass { get; set; }
    5. }
    6. public class SomeColumn
    7. {
    8. [CssClass("extra-class")]
    9. public string CellWithExtraClass { get; set; }
    10. }

    HeaderCssClass Attribute

    namespace: Serenity.ComponentModel, assembly: Serenity.Core

    Sets CSS class for grid column headers.

    • This has no effect for forms.

    • It sets headerCss property of SlickColumn, which adds this class to slick header for that column.

    AlignCenter Attribute

    namespace: Serenity.ComponentModel, assembly: Serenity.Core

    Centers text horizontally.

    • Used to control text alignment in grids by adding align-center CSS class to corresponding SlickGrid column.

    • Column headers are not affected by this attribute. You may use [HeaderCssClass("align-center")] for that.

    • Note that it has no effect on editors or forms.

    AlignRight Attribute

    namespace: Serenity.ComponentModel, assembly: Serenity.Core

    Right aligns text horizontally.

    • Used to control text alignment in grids by adding align-right CSS class to corresponding SlickGrid column.

    • Column headers are not affected by this attribute. You may use [HeaderCssClass("align-right")] for that.

    • Note that it has no effect on editors or forms.

    namespace: Serenity.ComponentModel, assembly: Serenity.Core

    Skips a property while generating grid column or form field list.

    • Use this to ignore a property for UI, but still use it for other purposes like
      JSON serialization.

    • This might be useful when a type is used as a Service Request and Form
      Declaration at the same time.

    1. public class SomeColumns
    2. {
    3. [Ignore]
    4. public string DontGenerateAColumnForMe { get; set; }