Masks


Configuring Masks in Grid Fields


To configure masks, go to the File Type settings, find the grid-type field you want to configure, and select the button to load the list of columns.




Go to the grid configuration screen, where you can create new columns or modify existing one




The attributes that can be defined for a grid column are as follows:


  • Name: Identifies the column with a key.
  • Label: The name displayed to the user when working with the grid.
  • Length: Represents the space in pixels that the column occupies.
  • Mask: Determines the allowable keyboard input values for each character.
  • Validator: Allows adding a validation after the column value is entered.
  • Key: Indicates that the column contains a value representing a key in a relationship with another subset of Files. If correct, it enables navigation to the related File.
  • Sortable: Allows the user to sort the grid by this column.
  • Read-Only: Disables interaction through the keyboard.
  • Date: Indicates that the column contains dates in the format day/month/year (dd/mm/yyyy).
  • Amount: Indicates that the column contains decimal numbers.
  • Summable: Always displays (in the header) the sum of the column values for all rows in the grid.

It is important to note that the selection fields for defining "Date" and "Amount" are retained for compatibility with earlier versions, even if they can be determined using regular expressions (ER).

When selecting "Date" or "Amount," the "Mask" and "Validator" options are disabled. The "Summable" option remains selectable even if the column is not numeric, as it only activates when it finds numeric values, without affecting grid functionality if none are present.


Mask


Both the mask and the validator work using a regular expression format (hereafter referred to as RE).


The difference lies in the fact that the mask must define a regular expression for each individual value.


For example, if you only want to allow a Tax ID (00-00000000-0), it must contain exactly 11 numeric digits. After the first two digits, a dash “-” is inserted, followed by 8 digits, then another dash “-”, and finally a single digit.


TaxId=>00-00000000-0


Each position starts with 0, which indicates that this position is evaluated using a regular expression with a numeric digit (0–9). Example: we enter 00, then a dash "-", indicating the separation, followed by eight 0s, another dash "-", and finally another 0.


It is important to note that in the third and twelfth positions, we only want to allow a hyphen (“-”), so we do not start those positions with the slash “-” to indicate a regular expression. What this means is that we are simply allowing the hyphen (“-”) in these positions.


Validator


This function allows you to validate the entire field upon exiting it. There are situations where defining a mask is complex, but an overall RE (regular expression) can be used. It alerts the user once the value is entered.


Continuing with the tax ID example, an expression like the following can be used:


^(20|27|23|24|25|26|30)-\d\d\d\d\d\d\d\d-\d


This RE is interpreted as follows: It can only start with the values 20, 27, 23, 24, 25, 26, or 30. Then a "-" is entered, followed by 8 digits (0 to 9), another "-", and finally a single digit (0 to 9).


It is similar to the previous example but provides greater control by allowing only specific numbers at the beginning.


There is no single RE to determine a value; multiple expressions can be used, and you must choose the most appropriate one. You can use tools like regex101.com for assistance.




Preloading Masks and Validators


As you identify common field types, you can save them in Netcontent for use in future implementations.


This is done by loading the "NC_CamposMascaras" table. Entries can only be added through the database.


  • [MaskIdField] is an auto-increment field that provides a unique ID for each entry.
  • [TypeField] is the identifier for the field type for which the mask is defined, such as 'Tax ID,' 'Email,' etc.


This value is presented when the format is not met, helping to contextualize the error. Therefore, when used, the value is concatenated at the beginning of the RE.


TaxId=>00-00000000-0


[[MaskField] is the RE string separated by "/," as seen previously.

[ValidatorField] is the RE string, as described earlier.


Having these expressions preloaded simplifies the definition of columns and fields in the File Type, as they are readily available for use.


They are simply shortcuts, as you can define your own  or edit them.



Created with the Personal Edition of HelpNDoc: Bring your WinHelp HLP help files into the present with HelpNDoc's easy CHM conversion