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.
Native SQL
Direct native database query to determine dictionary data, directly for a Property in the RGO_DictionaryItems
option setting.
- 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.
- 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.
- RGO_DictionaryItems: CategoryID,CategoryName,CategoryName
Static
Defining a static dictionary for a field in a simple JSON format.
- 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.
- RGO_DictionaryItems: <%%>DropdownRecroDict
- RGO_Nullable: true
- 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 Enum
as 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.
- 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.
- 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.
- 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.
- 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"),
];
}