Color Field

From Sense/Net Wiki
Jump to: navigation, search
  •  
  •  
  •  
  •  
  • 100%
  • 6.3
  • Enterprise
  • Community
  • Planned

Overview

Color Field is used for storing color code in hex. It can be configured and displayed as a color palette with predefined colors or as a color picker.

Color palette
Color picker

Details

The color field's color palette and color picker is based on 'kendoui ColorPicker control'.

Field handler

  • handler: SenseNet.ContentRepository.Fields.ColorField
  • short name: Color

Usage in CTD:

   <Field name="Color" type="Color">
   ...
   </Field>

Supported Field Controls

  • ColorPicker Field Control: it is based on a simple textbox control where user can edit value (if non-readonly) and based on the field's configuration it has a color picker or a color palette. Without predefined colors in 'Palette' property, the Color control will be displayed as a color picker.

Configuration

The following properties can be set in the Field's Field Setting configuration:

  • ReadOnly: a boolean property defining whether the Field data can be edited. If it is set to true, the Field is rendered as label instead of textbox.
  • Compulsory: a boolean property defining whether the Field has to contain any data. If it is set to true, but Field doesn't contain any data the portal displays an error message on saving this content.
  • DefaultValue: specifies the value filled in, when a new content is added.
  • Palette: contains a list of color codes in hex. The color codes must be separated by comma. (e.g. #f0d0c9;#e2a293;#d4735e;#65281a)

For a complete list of common Field Setting configuration properties see CTD Field definition.

Example/Tutorials

Fully featured example:

<Field name="Color1" type="Color">
      <DisplayName>Car Color</DisplayName>
      <Description>Field for storing the color of the car.</Description>
      <Configuration>
        <ReadOnly>false</ReadOnly>
        <Compulsory>true</Compulsory>
        <DefaultValue>#ff0000</DefaultValue>
        <Palette>#ff0000;#f0d0c9;#e2a293;#d4735e;#65281a</Palette>
      </Configuration>
</Field>

The above example configures the Color Field so that:

  • default value is set to red
  • Field value is editable (not read-only)
  • The control will display as a color palette, with the following selectable colors: #ff0000;#f0d0c9;#e2a293;#d4735e;#65281a

Related links

References