This example show how to add a grid in a Form.
We’ll add 2 grids in a custom tab of the “Project and management and accounting parameters” Form (ProjParameters)
This is the the result we will obtain

Create an extension of the “ProjParameters” Form and add a new datasource. The datasource points to the custom table “Al0ProjBudgetCalculationExcludedcategoriesCost”.

In the custom tab “Al0ProjParameters” ad a new group “Al0Group” with a custom pattern.
Under this create another group “Al0BudgetControl”

Add a checkbox that points to a newly create field of the ProjParameters field

Add a new group and insert a grid control


Add Data source of the grid control. In this case will be the custom table “Al0ProjBudgetCalculationExcludedCategoriesCost”

Add fields to the grid

Add grid buttons (New and Delete buttons)


Now implement some grid rules.
If field “Valid For” = Table then Project will be mandatory else No…

To do this you must create a class handler for the form
You must use eventHandler for events :
- Data source OnCreated event
- TableAll OnModified event


this is the code you must implement in a new class
/// <summary> /// EventHadler Class for ProjParameters Form /// </summary> class Al0ProjParameters_Handler { /// <summary> /// Al0ProjBudgetCalculationExcludedCategoriesRevenue_OnCreated event handler for Al0ProjBudgetCalculationExcludedCategoriesRevenue datasource /// </summary> /// <param name="sender"></param> /// <param name="e"></param> [FormDataSourceEventHandler(formDataSourceStr(ProjParameters, Al0ProjBudgetCalculationExcludedCategoriesRevenue), FormDataSourceEventType::Created)] public static void Al0ProjBudgetCalculationExcludedCategoriesRevenue_OnCreated(FormDataSource sender, FormDataSourceEventArgs e) { //Al0_0266_ProjBudgetExcludedCategoryItm - BEGIN Al0ProjBudgetCalculationExcludedCategoriesRevenue al0ProjBudgetCalculationExcludedCategoriesRevenue; al0ProjBudgetCalculationExcludedCategoriesRevenue = sender.cursor() as Al0ProjBudgetCalculationExcludedCategoriesRevenue; Al0ProjParameters_Handler::updateDesign_ProjId(al0ProjBudgetCalculationExcludedCategoriesRevenue.TableAll, sender.object(fieldNum(al0ProjBudgetCalculationExcludedCategoriesRevenue, ProjId))); //Al0_0266_ProjBudgetExcludedCategoryItm - END } /// <summary> /// Al0ProjBudgetCalculationExcludedCategoriesCost_OnCreated event handler for Al0ProjBudgetCalculationExcludedCategoriesCost datasource /// </summary> /// <param name="sender"></param> /// <param name="e"></param> [FormDataSourceEventHandler(formDataSourceStr(ProjParameters, Al0ProjBudgetCalculationExcludedCategoriesCost), FormDataSourceEventType::Created)] public static void Al0ProjBudgetCalculationExcludedCategoriesCost_OnCreated(FormDataSource sender, FormDataSourceEventArgs e) { //Al0_0266_ProjBudgetExcludedCategoryItm - BEGIN Al0ProjBudgetCalculationExcludedCategoriesCost al0ProjBudgetCalculationExcludedCategoriesCost; al0ProjBudgetCalculationExcludedCategoriesCost = sender.cursor() as Al0ProjBudgetCalculationExcludedCategoriesCost; Al0ProjParameters_Handler::updateDesign_ProjId(al0ProjBudgetCalculationExcludedCategoriesCost.TableAll, sender.object(fieldNum(Al0ProjBudgetCalculationExcludedCategoriesCost, ProjId))); //Al0_0266_ProjBudgetExcludedCategoryItm - END } /// <summary> /// TableAll_OnModified event handler for Al0ProjBudgetCalculationExcludedCategoriesCost datasource /// </summary> /// <param name="sender"></param> /// <param name="e"></param> [FormDataFieldEventHandler(formDataFieldStr(ProjParameters, Al0ProjBudgetCalculationExcludedCategoriesCost, TableAll), FormDataFieldEventType::Modified)] public static void TableAllCosts_OnModified(FormDataObject sender, FormDataFieldEventArgs e) { //Al0_0266_ProjBudgetExcludedCategoryItm - BEGIN TableAll tableAll; tableAll = sender.getValue(); Al0ProjParameters_Handler::updateDesign_ProjId(tableAll, sender.datasource().object(fieldNum(Al0ProjBudgetCalculationExcludedCategoriesCost, ProjId))); //Al0_0266_ProjBudgetExcludedCategoryItm - END } /// <summary> /// TableAll_OnModified event handler for Al0ProjBudgetCalculationExcludedCategoriesRevenue datasource /// </summary> /// <param name="sender"></param> /// <param name="e"></param> [FormDataFieldEventHandler(formDataFieldStr(ProjParameters, Al0ProjBudgetCalculationExcludedCategoriesRevenue, TableAll), FormDataFieldEventType::Modified)] public static void TableAllRevenue_OnModified(FormDataObject sender, FormDataFieldEventArgs e) { //Al0_0266_ProjBudgetExcludedCategoryItm - BEGIN TableAll tableAll; tableAll = sender.getValue(); Al0ProjParameters_Handler::updateDesign_ProjId(tableAll, sender.datasource().object(fieldNum(Al0ProjBudgetCalculationExcludedCategoriesRevenue, ProjId))); //Al0_0266_ProjBudgetExcludedCategoryItm - END } private static void updateDesign_ProjId(TableAll _tableAll, FormDataObject _projIdControl) { //If Al0ProjBudgetCalculationExcludedCategoriesCost datasource field --> tableAll = "All" then disable and empty ProjId field if(_tableAll == TableAll::All) { _projIdControl.enabled(false); _projIdControl.setValue(""); _projIdControl.mandatory(false); } else { _projIdControl.enabled(true); _projIdControl.mandatory(true); } //Al0_0266_ProjBudgetExcludedCategoryItm - END } }