// Form Creation through Code in ax .. For Dynamic Form Creation
static void DynamicFormAX(Args _args)
{
DictTable dictTable;
Form form;
FormBuildDesign design;
FormBuildDataSource dataSource;
FormBuildActionPaneControl actionPane;
FormBuildActionPaneTabControl actionPaneTab;
FormBuildButtonGroupControl buttonngroup1;
FormBuildButtonGroupControl buttonngroup2;
FormBuildCommandButtonControl cmdNew;
FormBuildCommandButtonControl cmdDel;
FormBuildMenuButtonControl menubuttonPosting;
FormBuildFunctionButtonControl menuFuncbuttonPosting;
FormBuildFunctionButtonControl menuFuncbuttonForecast;
FormBuildGridControl grid;
FormBuildGroupControl grpBody;
Args args;
FormRun formRun;
#Task
dictTable = new DictTable(tableNum(CustGroup));
form = new Form();
form.name("CustGroupDynamic");
dataSource = form.addDataSource(dictTable.name());
dataSource.table(dictTable.id());
design = form.addDesign('Design');
design.caption("Customer groups");
design.style(FormStyle::SimpleList);
design.titleDatasource(dataSource.id());
actionPane = design.addControl(FormControlType::ActionPane, 'ActionPane');
actionPane.style(ActionPaneStyle::Strip);
actionPaneTab = actionPane.addControl(FormControlType::ActionPaneTab, 'ActionPaneTab');
buttonngroup1 = actionPaneTab.addControl(FormControlType::ButtonGroup, 'NewDeleteGroup');
buttonngroup2 = actionPaneTab.addControl(FormControlType::ButtonGroup, 'ButtonGroup');
cmdNew = buttonngroup1.addControl(FormControlType::CommandButton, 'NewButton');
cmdNew.buttonDisplay(FormButtonDisplay::TextAndImageLeft);
cmdNew.normalImage('11045');
cmdNew.imageLocation(SysImageLocation::EmbeddedResource);
cmdNew.primary(NoYes::Yes);
cmdNew.command(#taskNew);
cmdDel = buttonngroup1.addControl(FormControlType::CommandButton, 'NewButton');
cmdDel.text("Delete");
cmdDel.buttonDisplay(FormButtonDisplay::TextAndImageLeft);
cmdDel.normalImage('10121');
cmdDel.imageLocation(SysImageLocation::EmbeddedResource);
cmdDel.saveRecord(NoYes::Yes);
cmdDel.primary(NoYes::Yes);
cmdDel.command(#taskDeleteRecord);
/*menubuttonPosting = buttonngroup2.addControl(FormControlType::MenuButton, 'MenuButtonPosting');
menubuttonPosting.helpText("Set up related data for the group.");
menubuttonPosting.text("Setup");
menuFuncbuttonPosting = menubuttonPosting.addControl(FormControlType::MenuFunctionButton, 'Posting');
menuFuncbuttonPosting.text('Item posting');
menuFuncbuttonPosting.saveRecord(NoYes::No);
menuFuncbuttonPosting.dataSource(dataSource.id());
menuFuncbuttonPosting.menuItemName(menuitemDisplayStr(InventPosting));
menuFuncbuttonForecast = buttonngroup2.addControl(FormControlType::MenuFunctionButton, 'SalesForecast');
menuFuncbuttonForecast.text('Forecast');
menuFuncbuttonForecast.saveRecord(NoYes::No);
menuFuncbuttonForecast.menuItemName(menuitemDisplayStr(ForecastSalesGroup));*/
grpBody = design.addControl(FormControlType::Group, 'Body');
grpBody.heightMode(FormHeight::ColumnHeight);
grpBody.columnspace(0);
grpBody.style(GroupStyle::BorderlessGridContainer);
grid = grpBody.addControl(FormControlType::Grid, "Grid");
grid.dataSource(dataSource.name());
grid.widthMode(FormWidth::ColumnWidth);
grid.heightMode(FormHeight::ColumnHeight);
grid.addDataField(dataSource.id(), fieldNum(CustGroup,CustGroup));
grid.addDataField(dataSource.id(), fieldNum(CustGroup,Name));
grid.addDataField(dataSource.id(), fieldNum(CustGroup,PaymTermId));
grid.addDataField(dataSource.id(), fieldnum(CustGroup,ClearingPeriod));
grid.addDataField(dataSource.id(), fieldNum(CustGroup,BankCustPaymIdTable));
grid.addDataField(dataSource.id(), fieldNum(CustGroup,TaxGroupId));
args = new Args();
args.object(form);
formRun = classFactory.formRunClass(args);
formRun.init();
formRun.run();
formRun.detach();
}
static void DynamicFormAX(Args _args)
{
DictTable dictTable;
Form form;
FormBuildDesign design;
FormBuildDataSource dataSource;
FormBuildActionPaneControl actionPane;
FormBuildActionPaneTabControl actionPaneTab;
FormBuildButtonGroupControl buttonngroup1;
FormBuildButtonGroupControl buttonngroup2;
FormBuildCommandButtonControl cmdNew;
FormBuildCommandButtonControl cmdDel;
FormBuildMenuButtonControl menubuttonPosting;
FormBuildFunctionButtonControl menuFuncbuttonPosting;
FormBuildFunctionButtonControl menuFuncbuttonForecast;
FormBuildGridControl grid;
FormBuildGroupControl grpBody;
Args args;
FormRun formRun;
#Task
dictTable = new DictTable(tableNum(CustGroup));
form = new Form();
form.name("CustGroupDynamic");
dataSource = form.addDataSource(dictTable.name());
dataSource.table(dictTable.id());
design = form.addDesign('Design');
design.caption("Customer groups");
design.style(FormStyle::SimpleList);
design.titleDatasource(dataSource.id());
actionPane = design.addControl(FormControlType::ActionPane, 'ActionPane');
actionPane.style(ActionPaneStyle::Strip);
actionPaneTab = actionPane.addControl(FormControlType::ActionPaneTab, 'ActionPaneTab');
buttonngroup1 = actionPaneTab.addControl(FormControlType::ButtonGroup, 'NewDeleteGroup');
buttonngroup2 = actionPaneTab.addControl(FormControlType::ButtonGroup, 'ButtonGroup');
cmdNew = buttonngroup1.addControl(FormControlType::CommandButton, 'NewButton');
cmdNew.buttonDisplay(FormButtonDisplay::TextAndImageLeft);
cmdNew.normalImage('11045');
cmdNew.imageLocation(SysImageLocation::EmbeddedResource);
cmdNew.primary(NoYes::Yes);
cmdNew.command(#taskNew);
cmdDel = buttonngroup1.addControl(FormControlType::CommandButton, 'NewButton');
cmdDel.text("Delete");
cmdDel.buttonDisplay(FormButtonDisplay::TextAndImageLeft);
cmdDel.normalImage('10121');
cmdDel.imageLocation(SysImageLocation::EmbeddedResource);
cmdDel.saveRecord(NoYes::Yes);
cmdDel.primary(NoYes::Yes);
cmdDel.command(#taskDeleteRecord);
/*menubuttonPosting = buttonngroup2.addControl(FormControlType::MenuButton, 'MenuButtonPosting');
menubuttonPosting.helpText("Set up related data for the group.");
menubuttonPosting.text("Setup");
menuFuncbuttonPosting = menubuttonPosting.addControl(FormControlType::MenuFunctionButton, 'Posting');
menuFuncbuttonPosting.text('Item posting');
menuFuncbuttonPosting.saveRecord(NoYes::No);
menuFuncbuttonPosting.dataSource(dataSource.id());
menuFuncbuttonPosting.menuItemName(menuitemDisplayStr(InventPosting));
menuFuncbuttonForecast = buttonngroup2.addControl(FormControlType::MenuFunctionButton, 'SalesForecast');
menuFuncbuttonForecast.text('Forecast');
menuFuncbuttonForecast.saveRecord(NoYes::No);
menuFuncbuttonForecast.menuItemName(menuitemDisplayStr(ForecastSalesGroup));*/
grpBody = design.addControl(FormControlType::Group, 'Body');
grpBody.heightMode(FormHeight::ColumnHeight);
grpBody.columnspace(0);
grpBody.style(GroupStyle::BorderlessGridContainer);
grid = grpBody.addControl(FormControlType::Grid, "Grid");
grid.dataSource(dataSource.name());
grid.widthMode(FormWidth::ColumnWidth);
grid.heightMode(FormHeight::ColumnHeight);
grid.addDataField(dataSource.id(), fieldNum(CustGroup,CustGroup));
grid.addDataField(dataSource.id(), fieldNum(CustGroup,Name));
grid.addDataField(dataSource.id(), fieldNum(CustGroup,PaymTermId));
grid.addDataField(dataSource.id(), fieldnum(CustGroup,ClearingPeriod));
grid.addDataField(dataSource.id(), fieldNum(CustGroup,BankCustPaymIdTable));
grid.addDataField(dataSource.id(), fieldNum(CustGroup,TaxGroupId));
args = new Args();
args.object(form);
formRun = classFactory.formRunClass(args);
formRun.init();
formRun.run();
formRun.detach();
}
No comments:
Post a Comment