Skip to content

Commit

Permalink
Adds info about DataListItem attribute (#321)
Browse files Browse the repository at this point in the history
* Adds info about DataListItem attribute

I needed a way to extend the information about enums in data lists, and found it in the source code. So why not add some documentation? :)
  • Loading branch information
skttl authored May 15, 2023
1 parent a6fb239 commit 49a8106
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions docs/data-sources/data-source--enum.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,38 @@ Select the desired enumeration, by selecting the containing .NET assembly, and t
The value returned from the List editor is the configured enumeration type.

Depending on the `List editor` used, this may be wrapped in a `List<T>`.

##### Controlling Enum display

You can use the [DataListItemAttribute](../../src/Umbraco.Community.Contentment/DataEditors/DataList/DataListItemAttribute.cs) to decorate your enum values with additional information for use with Contentment. With this attribute, you can specify properties such as name, description, icon, etc., for individual enum items.

For example:

```csharp
using Umbraco.Community.Contentment.DataEditors;

public enum MyEnum
{
[DataListItem(Description = "This is the first value", Group = "Group A", Icon = "icon-first")]
First,

[DataListItem(Description = "This is the second value", Group = "Group B", Icon = "icon-second")]
Second,

[DataListItem(Description = "This is the third value", Group = "Group A", Icon = "icon-third")]
Third
}
```

The `DataListItemAttribute` contains the following properties:

| Property | Description | Type |
|-------------|------------------------------------------------------------------|---------|
| Description | Provides a description for the Enum value | string |
| Disabled | Specifies whether the Enum value should be disabled | bool |
| Group | Assigns the Enum value to a specific group | string |
| Icon | Specifies an icon for the Enum value | string |
| Ignore | Indicates whether the Enum value should be ignored | bool |
| Name | Provides a custom name for the Enum value (default: field name) | string |
| Value | Specifies a custom value for the Enum value (default: field value)| string |

0 comments on commit 49a8106

Please sign in to comment.