A data container in a TStruct with its AsGrid property set to True is a Grid DC. Each field in the DC is created as a column in the grid.
An invoice or a bill usually has two sections – a header section with fields like Document No, Date, Customer Name, Address, etc and a detail section in which list of products, quantity, rate and amount are entered. One customer can buy many products and hence the detail section should be in a grid format. Therefore, when you create a TStruct corresponding to the bill , you need to define a header DC and a details DC and the AsGrid property of the detail DC should be set to true.
Points to remember
- The first DC in a TStruct cannot be a grid DC.
- The table related to the grid DC is called the grid table. The table of the primary DC (first DC in the TStruct) is called the primary table. The table id of the primary table is created as a field in the grid table. So, when transactions are entered, for every row in primary table there can be many rows in the grid table. The rows in the primary table are related to the grid table through the primary table id.
- The data width decides the size of the field in the database table. Its size on the form can be set by resizing the column in the form designer.
- Fields in the grid DC also can have rules similar to normal DC fields .The selection fields will provide a drop down when the user starts entering values in the cell. A selection field with dynamic filter in the grid will be displayed with a pick list.
- Rows can be added to the grid. When rows are added, the automated fields are filled with values automatically.
- Rows can be deleted from the grid. One or more fields in the grid may have dependent fields outside the grid. These dependent fields are called grid dependent fields. All the grid dependent fields will be refreshed when a row is deleted from the grid.
Keywords in Grid Dc
In a grid DC, an input field named axp_valid+dcnumber (for dc2 the fieldname would be : axp_valid2) can be created. If the value in this field is a, the row can be edited & deleted. b in this field means the row cannot be deleted. c in this field means the row cannot be edited and cannot be deleted. The value can be filled based on business rules.
A field named validrow+dcnumber can be used to control the validity of a row. If the value in this field is T(True) then the row is considered as a valid row. Only valid rows will be saved to the database.
Wordwrapping headings in Grid DC
You can have more than one title row in a grid DC in a Tstruct. To wrap column headings, use ‘~’ character as the separator. For eg, to display “Employee name” as “Employee” in first line & “name” in second line, set the caption as “Employee~name”.
Grid color property
This property can be used to set the color of the grid in a DC in a Tstruct. This option is available when right clicked on the grid in the form designer. This option is applicable only for desktop versions.