static void ShowStagingTableForMessage(CG_EDI_EDIMessageStatus _message)
{
Args args;
Form form;
FormRun formRun;
FormBuildDesign formBuildDesign;
FormBuildDataSource formBuildDataSource;
FormBuildGridControl formBuildGridControl;
FormBuildTabControl formBuildTabControl;
FormBuildTabPageControl formBuildTabPageControl;
FormStringControl formStringControl;
FormGridControl formGridControl;
FormDataSource formDataSource;
DictTable dictTable;
int idx = 0;
CG_EDI_InterfaceSection interfaceSection;
TableName stagingTableName;
CG_EDI_InterfaceSectionId sectionName;
Map map;
MapEnumerator mapEnum;
QueryBuildDataSource qbds;
QueryBuildRange qbr;
map = new Map(Types::String, Types::String);
// Create the form header.
form = new Form();
// Create the form design.
formBuildDesign = form.addDesign("Design");
formBuildDesign.caption("@CG_EDI_Label:MessageStagingTables");
formBuildDesign.showDeleteButton(0);
formBuildDesign.showNewButton(0);
// Add tabbed page controls, a grid control, and string controls.
formBuildTabControl = formBuildDesign.addControl(FormControlType::Tab, "Overview");
formBuildTabControl.style(TabStyle::FastTabs);
formBuildTabControl.arrangeMethod(FormArrangeMethod::Vertical);
formBuildTabControl.heightMode(FormHeight::SizeToContent);
//** Loop Interface Sections **//
while select interfaceSection order by Sequence where interfaceSection.InterfaceDefinition == _message.InterfaceDefinition && interfaceSection.SectionStagingTable != ''
{
if (interfaceSection)
{
if (!map.exists(interfaceSection.SectionStagingTable))
{
map.insert(interfaceSection.SectionStagingTable, interfaceSection.InterfaceSectionId);
}
else
{
map.insert(interfaceSection.SectionStagingTable, map.lookup(interfaceSection.SectionStagingTable));
}
}
}
if (!map.empty())
{
mapEnum = map.getEnumerator();
while (mapEnum.moveNext())
{
idx++;
stagingTableName = mapEnum.currentKey();
sectionName = mapEnum.currentValue();
dictTable = new DictTable(tablename2id(stagingTableName));
// Add a data source to the form
formBuildDataSource = form.addDataSource(dictTable.name());
formBuildDataSource.table(dictTable.id());
// TabPage Control
formBuildTabPageControl = formBuildTabControl.addControl(FormControlType::TabPage, sectionName+enum2Str(FormControlType::TabPage));
formBuildTabPageControl.caption(sectionName);
formBuildTabPageControl.heightMode(FormHeight::SizeToContent);
if (idx == 1)
{
formBuildTabPageControl.fastTabExpanded(FastTabExpanded::Always);
}
else
{
formBuildTabPageControl.fastTabExpanded(FastTabExpanded::Auto);
formBuildTabPageControl.verticalScrollBarVisible(true);
}
// Grid Control
formBuildGridControl = formBuildTabPageControl.addControl(FormControlType::Grid,sectionName+enum2Str(FormControlType::Grid));
if (idx == 1)
{
formBuildGridControl.visibleRowsMode(AutoMode::Fixed);
formBuildGridControl.visibleRowsValue(1);
formBuildGridControl.visibleRows(1);
formBuildGridControl.heightMode(FormHeight::SizeToContent);
}
else
{
formBuildGridControl.visibleRowsMode(AutoMode::fixed);
formBuildGridControl.visibleRows(10);
formBuildGridControl.visibleRowsValue(10);
formBuildGridControl.heightMode(FormHeight::SizeToAvailable);
}
// Add data fields to Grid
CG_EDI_EDIMessageStatus::addFields2Grid(dictTable, formBuildGridControl,formBuildDataSource);
}
}
args = new Args();
args.object(form);
// Create the run-time form.
formRun = classfactory.formRunClass(args);
formRun.init();
// filter the selected message's ExecutionId
for (int i = 1; i <= idx; i++)
{
formDataSource = formRun.dataSource(i);
qbds = formDataSource.query().dataSourceNo(1);
qbds.firstFast(false);
qbds.firstOnly(false);
qbr = qbds.addRange(fieldName2Id(qbds.table(),"ExecutionId"));
qbr.value(_message.ExecutionId);
qbr.status(RangeStatus::Hidden);
formDataSource.executeQuery();
int counter = formDataSource.numberOfRowsLoaded(); // => this counter shows 3 records for the second datasource!
}
formRun.run();
formRun.detach();
}
and this is how my form shows up: