subtypes
As described in Data Type, RealGrid DataProvider's DataField can be one of four data types. However, it is common for primitive data types to be used to a limited extent in work environments. RealGrid supports the Subtype property per DataField to support some of these requirements. Subtype can be specified when adding a data field, and the "subtype" indicator and "set" and "min"/"max" qualifiers can be used. However, Subtype is not the data type of the data field, but only serves to fit the value of the field into the specified range when it is stored in the DataProvider. In other words, existing data saved at the time when subtype application is canceled or data saved by applying another subtype are not adjusted to the new subtype. Of course, it is possible to have the UI or other functions operate according to the specified Subtype in addition to the role of the storage range.
1). subtype indicator
When specifying a data field, it can be set as the "subType" property. The values that can be set for each basic data type are as follows.
Text | "char" - Stored as a string of limited length with a "length" property greater than 0. |
If "length" is specified as 0 or less, it is the same as the basic data type "text". | |
Number | "unum" - Stored as a number greater than or equal to 0. |
"int" - Stored as an integer value. | |
Stored in the same way as i = v >= 0 ? Math.floor(v) : Math.ceil(v). | |
In other words, if it is 1.1, it is stored as 1, and if it is -1.1, it is stored as -1. | |
"uint" - Stored as an integer value greater than or equal to 0. | |
Stored in the following way i = Math.floor(v);. | |
Datetime | "date" - The date value is saved with the time part removed. |
"fields": [{
"fieldName": "ItemId",
"dataType": "number",
"subType": "unum"
},{
"fieldName": "ItemName",
"dataType": "text",
"subType": "char",
"length": 100
},{
...
}];
2). minimum/maximum
When adding a DataField, you can specify the "min" or "minimum" and "max" or "maximum" properties to set the range in which the value is stored. Values beyond the boundary are stored as boundary values. That is, values less than min are stored as min, and values greater than max are stored as max. You can specify either the minimum or minimum value, and if you specify the maximum value less than the minimum value, this range will be ignored. These properties can be specified for Number and Datetime data types. When specifying this property for a Datetime field, specify it as a string that matches the field's datatimeFormat or, if not specified for the field, the datetimeFormat set in the DataProvider.
"fields": [{
"fieldName": "Price",
"dataType": "number",
"min": 100,
"max": 200
...
3). set
You can specify the "set" array property value on DataFields of data types other than the Boolean data type so that if the value is not included in the array, it is stored as undefined.
"fields": [{
"fieldName": "State",
"set": ["ab", "cd", ...],
...
4). caution
As pointed out above, RealGrid Subtype is a type of constraint that adjusts the input value to a value within the range without causing an error. You can disable or re-enable the subtype function with the subtypeEnabled property of DataProvider. Additionally, if subtypeEnabled is set to true in the DataProvider, subtypeEnabled for each data field can be activated/deactivated through the property.
The Subtype setting is applied just before the requested field value is stored in the DataProvider, such as when adding/changing rows.