Guide to Applications

How to Group Data Elements

In C1 CMS, you can group data items by one or more fields provided that some of the data items share the same values in those fields. Data folder elements allow you to group data elements in your console applications.

Figure 18: Data folder elements

Grouping can be hierarchical if you use more than one field to group by. (Read more on grouping data items in Field Grouping and Creating Datatypes That Reference Other DataTypes)

Normally, data folder elements of a specific type should contain data elements (DataElements) of the same type. The data folder elements can also contain other data folder elements of the same type. In this case, the top data folder elements must be distinguished from their child data folders because they might have different attributes to set.

To group data elements, you should use a DataFolderElements element:

  1. Locate an element to serve as a parent.
  2. Add a Children element within this parent element.
  3. Add a DataFolderElements element within the Children element.
  4. Specify its required attribute:
    • Type: The data interface type name
    • FieldGroupingName: The field name of the given data interface (property name) to group by

    If necessary, specify its optional attributes:

    • DateFormat: Date format used when grouping
    • Range: Ranges for grouping data folders
    • FirstLetterOnly: When set to “true” the grouping is done with the first letter only
    • Display: A mode in which an element that might have child elements is displayed
    • Icon: The icon of the element
    • SortDirection: The sorting direction (Note: Composite C1 (now C1 CMS) 4.0 or later.)
    <DataFolderElements  Type="Composite.Community.Blog.Entries"  DateFormat="yyyy MMMM"  FieldGroupingName="Date"  Display="Compact">
    </DataFolderElements>

    Listing 17: Using DataFolderElements

    To have a child data folder within the above parent data folder:

  5. Add a Children element within the DataFolderElements element.
  6. Add another DataFolderElements element within the Children element.
  7. Specify its required attribute:
  • FieldGroupingName: The field name of the given data interface (property name) to group by

If necessary, specify its optional attributes:

  • DateFormat: Date format used when grouping
  • Range: Ranges for grouping data folders
  • FirstLetterOnly: When set to “true” the grouping is done with the first letter only
  • Display: A mode in which an element that might have child elements is displayed
  • Icon: The icon of the element
  • ShowForeignItems: When set to “true”, data folder items not yet localized are displayed with a “Localize” action
  • SortDirection: The sorting direction (Note: Composite C1 (now C1 CMS) 4.0 or later.)

Please note that for child data folders within a parent data folder you do not need to specify the Type attribute again. However, you can specify the ShowForeignItems attribute (unavailable for the parent data folder.)