Table of Contents

Dictionaries

Dictionaries can be used in the drop-down lists of the RecroGrid Framework's Form views, and the text to be displayed can also appear in the Grid view based on the key,allowing filtering. Various types of data sources can be configured to populate the dictionaries.

Tip

If the selection is based on another entity where a large amount of data is present, it is recommended to use the built-in entity selection instead of a dictionary.

Native SQL

Direct native database query to determine dictionary data, directly for a Property in the RGO_DictionaryItems option setting.

SECONDARY
  • FormType: DropDown
  • RGO_DictionaryItems: NSQL:select CategoryID, CategoryName from Categories order by 2

A dictionary entity with the type NSQL can be created. In this case, the dictionary can be used for multiple properties, for which the dictionary entity needs to be selected in the EntityBase. The entity definition is as follows.

SECONDARY
  • Name: CategoryDropdown
  • TypeDefinition: select CategoryID, CategoryName from Categories order by 2
  • Category: NSQL

Based on the entity

It is possible to define a dictionary based on an existing entity, which can be used for any property. The definition must be created within the entity itself using the RGO_DictionaryItems optional setting. In the definition, the key/value columns must be specified, and sorting can also be optionally provided.

SECONDARY
  • RGO_DictionaryItems: CategoryID,CategoryName,CategoryName

Static

Defining a static dictionary for a field in a simple JSON format.

SECONDARY
  • RGO_DictionaryItems: {1:Static-Item1;2:Static-Item2;3:Static-Item3}
  • RGO_Nullable: true

RecroDict - multilingual dictionary

Using the RecroDict dictionary based on Scope. The StringId is placed in the field, and the display text appears depending on the language used. If the key should also be used for the display text, it should be specified in the <%%>KK: format.

SECONDARY
  • RGO_DictionaryItems: <%%>DropdownRecroDict
  • RGO_Nullable: true
SECONDARY
  • Scope: DropdownRecroDict, StringId: 1, Str_eng: RD-Item1
  • Scope: DropdownRecroDict, StringId: 2, Str_eng: RD-Item2
  • Scope: DropdownRecroDict, StringId: 3, Str_eng: RD-Item3

Enum

Using an Enumas a dictionary. The values of the Enum are placed in the field, and the display text corresponds to the textual representation of the Enum. It is also possible to define DisplayAttribute for the textual values.

SECONDARY
  • RGO_DictionaryItems: Enum:RGF.API.Entities.DropdownEnumTest, DefaultAssemblyName
  • RGO_Nullable: true

The Enum value can be combined with the RecroDict dictionary, where the key is the Enum value and the display text is the value defined in the RecroDict.

SECONDARY
  • RGO_DictionaryItems: Enum<%%>DropdownRecroDict: RGF.API.Entities.DropdownEnumTest, DefaultAssemblyName
  • RGO_Nullable: true
public enum DropdownEnumTest
{
    [Display(Name = "Enum Item1")]
    EItem1 = 1,
    [Display(Name = "Enum Item2")]
    EItem2 = 2,
    [Display(Name = "Enum Item3")]
    EItem3 = 3
}

A dictionary entity with the type Enum can be created. In this case, the dictionary can be used for multiple properties, for which the dictionary entity needs to be selected in the EntityBase. The entity definition is as follows.

SECONDARY
  • Name: DropdownEnumTest
  • TypeDefinition: RGF.API.Entities.DropdownEnumTest, DefaultAssemblyName
  • Category: Enum

Callback

A dictionary can also be defined using a function callback, where the function's return value is the dictionary. The function should be placed in the RecroGrid class or the Entity model class.

SECONDARY
  • RGO_DictionaryItems: Callback:DropdownCallbackTest
  • RGO_Nullable: true
public static List<KeyValuePair<string, string>> DropdownCallbackTest(RGDictionaryCallbackParam arg)
{
    return
    [
        new ("1", "CB Item1"),
        new ("2", "CB Item2"),
        new ("3", "CB Item3"),
    ];
}

Next step

See Also