Agile Developer

Table fields

Axpert 11
TStructs (Forms)
IViews
Scripts
Axpert Jobs
Axpert Cards
HTML Plug-ins
Users & Roles
Workflow
Axpert API
Application Var/Params
Publish Axpert Apps
Axpert Mobile
Settings
Utilities
Customization
WebServices

Table fields

A table-field is a Collection Field Type (CFT). The properties of this field is provided as a JSON string in the Collection Field Descriptor(CFD). This is used to accept field values in a drop-down table in run time. The drop-down table will have columns & rows as described in the descriptor. The CFD value can be set as below :
{
“props”:{
“type“:“table”,
“colcount“:“4”,
“rowcount”:“5”,
"addrow":"t",
"deleterow":"t",
“valueseparator”:“|”,
“rowseparator”:“||”,
},
"columns":{
“col1”:{
“caption”:“Column one”,
"name":"name",
“value”:“v1”,
“source”:“ ”,
“exp”:“expression to calculate & populate”,
“vexp”:“expression to validate”
},
“col2”:{
}
}
}

At run time, the CFT will popup a table in which data can be entered by the user. The data entered by the user will be stored in the field as one string. The individual field values will be separated by the given value separator. The rows will be separated by a given row separator.
The “type” tag in the CFD can be set to table or form. Forms will be shown as name-value pairs.
The source tag may be set with a field name from the tstruct. This field is a drop-down field if the source field is a drop-down field. The drop-down values from the source are used as drop-down values for this field.

Example:
Consider a use-case where the user is entering the marks of a student:

  • Student name – Selection from a drop-down of students from student master.
  • Subject – Drop-down field
  • Mark – Accept
  • Mark details – Table field that pops up a table as below:
caption

The CFD for the above table would be:

{
"props": {
"type": "table",
"colcount": "3",
"rowcount": "1",
"addrow": "t",
"deleterow": "t",
"valueseparator": "|",
"rowseparator": "^"
},
"columns": {
"1": {
"caption": "Name",
"name": "name",
"value": "",
"source": "",
"exp": "",
"vexp": ""
},
"2": {
"caption": "Subject",
"name": "subject",
"value": "",
"source": "",
"exp": "",
"vexp": ""
}
,
"3": {
"caption": "Mark",
"name": "mark",
"value": "",
"source": "",
"exp": "",
"vexp": ""
},
"4": {
"caption": "Mark Details",
"name": "mark details",
"value": "",
"source": "",
"exp": "",
"vexp": ""
}
}
}

If the test type should be a drop-down, follow the steps given below:
1. Create a hidden field before the Mark details field named “HTestTypes” as a drop-down field.
2. Change the col1 definition in the CFD as below:

“col1”:{
“caption”:“Test type”,
“value”:“ ”,
“source”:“HTestTypes”
}

Another way of doing it is to create the HTestTypes field as a text field with an expression that returns the comma-separated string of the test types like Test -1, Test – 2, Term – 1. The comma-separated values will be converted into a drop-down for Col1.

Dynamic table fields

There is a property named Dynamic Source Field (DSF) for table-fields. This provides a drop-down of fields in this tstruct. In run time, the dynamic source field should be populated with the name of a table descriptor. The CFD defined in the selected table descriptor will be used to create the table in run time.
The Table descriptor option is under Utilities in the developer site. This option accepts a name for the descriptor and the collection field descriptor JSON.
In the above example if the subject is science, then a table as below should be displayed.

caption

Define the CFD for both tables as two different records in the Table descriptor option. Name the science table as SciDef and the earlier table definition as OthDef.
Create a field named MarksDSF as an expression field with expression iif(subject={Science}, {SciDef}, {OthDef}). Select this field in the Dynamic source field property for mark details table-field.
This is an extremely powerful concept that can be used for cases like EMR, Lab test forms, cost centers, budget apportioning, textile costing forms, and many more.
Consider an example of employee experience, where the employee can be fresher or experienced. Define the employee experience and use the definition in the Definition Source field as shown below.

Try Out

In the Employee form created use table field type for the employee experience parameter, and define a table that will include details like Previous Company Name, Experience in years, Current CTC.