Reports, such as sales reports, are often represented in columnar format where the same type of data is repeated on multiple lines in multiple columns, without having to worry about paging, column width, line height, and so on. For this type of report, the Data Grid component is used.
Drag the mvD report from the Component Store to the REPORT1 Library window.
Type rGridReport to name the mvD report Class.
Double-click rGridReport to open the design form, then drag the Entry field from the Component Store to the design form.
Select the External Components icon from the Component Store menu to display all the external components, then right-click the Component Store and select External components…
The External components-Library REPORT1 window displays.
Select External Component from the Component Libraries list.
A new Component Libraries list displays.
Select the Report Lists Library from the Component Libraries list and the Opening 'REPORT1' Pre-Load Status option, then click OK.
Select the External Components icon from the Component Store menu to display all the external components.
Drag the Data Grid from the Component Store to the REPORT1.rGridreport design form.
Define 5 columns (column sizes can be adjusted as required) and label the columns:
These properties are defined in the General tab, Appearance tab, and Column tab of the Property Manager window.
(Optional) Change the border, grid lines, and cell-heading color.
Assign a DataName (that holds the data) and a name for the rGridReport to define the field properties for the Data Grid component.
The DataName for the rGridReport must be the iMvdSubList variable. The iMvdSubList is an Omnis instance variable defined in the mvDesigner base Class. By default, this variable is defined with a maximum of 10 columns.
To view the variables defined in the mvDesigner base Class, double-click a Library Class design form to open the mvD Class Methods. The mvD Class Methods displays the base class variables used.
If the Data Grid contains more than 10 columns, then w3mvDDefineReportColumns(nColumns,SubListHA) is required.
Where nColumns is the number of columns required and SubListHA is the Header Array that defines the iMvdSubList table (it is also used in the w3mvDInsert to send the grid data to the report).
Close the report.
Select MyServer (Default) > Subroutines > mvDReport > bp BASIC program from the Enterprise Browser.
Right-click the bp node and select Create New Item...
A new BASIC program item is created.
Type GridReport to name the new item.
Double-click the GridReport node to open the GridReport Editor.
Edit the GridReport BASIC program.
CASE TRIGGERFORM = 'rGridReport' AND TRIGGEREVENT = '$getreportdata'
The GridReport BASIC program reacts to two events.
$getreportdata event from the rGridReport design form.
$print event from the Data Grid component.
The $getreportdata event starts the report and returns the report title. This event is required to generate the report even if there is no report title.
Since the $print event is only triggered when the report is in printing progress, it must be started by issuing the $getreportdata event.
The $print event of the Data Grid component is triggered when mvDesigner is ready to print the Data Grid. When this event is triggered, the BASIC program is called to build the list of data that is returned to the grid.
The data returned to the grid uses the special DataName as defined in the Configuring the Data Grid procedure. As stated before, the DataName of the Data Grid must be assigned to the Omnis instance variable iMvdSubList and the column names, Colx (where x is the column number).
In this example, the data in the Grid Report BASIC program needs to be returned to the list. The dynamic array HA defines the list in the BASIC program.
CASE TRIGGEROBJECT = "Grid" AND TRIGGEREVENT = "$print" GOSUB PrepareGridData
The GridReport BASIC program successfully compiles.
Select Subroutines > mvDReport > bp > GridReport node from the Enterprise Browser.
Right-click the GridReport node and select Catalog Item...
The mvDCatalog Entry window displays.
Select the Allow Anonymous Access check box, then click Save.
Double-click rGridReport Class from REPORT1 Library to open the REPORT1.rGridReport design form.
Select MyServer (Default) > DataNames > ReportTutorial > GridReport > Report > Header element from the Enterprise Browser, then drag the Header element to the rGridReport_1004 label.
The rGridReport_1004 window displays.
Click Update to save changes and close window.
Select MyServer (Default) > mvDCatalog > ReportTutorial > GridReport node from the Enterprise Browser.
Drag the GridReport node to the report in the REPORT1.rGrid Report design form.
The rGridReport event window displays.
Select the $getreportdata event check box, select MyServer from the Server drop-down list, then click Update to save the changes.
Since the DataNames were assigned earlier using the iMvdSubList instance variable, they do not need to be assigned to the Data Grid component.
Repeat procedure 4.
The Grid mvDCatalog window displays.
Select the $print event check box, then click Update to save changes.
Click the Print to Screen icon from the REPORT1.rGridReport design form to print and view and test the mvD report.
Select kTrue from the reportheader drop-down list to display a header on the report, then select kTrue from the pagefooter drop-down list to display a footer on the report to define the field properties.
Drag the iMvdDataRef.Header to the Report Heading section of the Report, then define its field properties in the Property Manager window.
Click the Background Components icon, then click the Background Objects icon from the Component Store Menu.
Drag the Label field to the Report Heading section of the design form, then define its field properties in the Property Manager window.
Click the External Components icon from the Component Store menu to display the components, then select the Page Count Object component.
Drag the Page Count Object from the Component Store to the Page Footer section of the design form, then define its field properties in the property manager window.
Select the Page Footer heading to display its field properties in the Property Manager window, then select kTrue from the firstpage drop-down list.
Click the Print to Screen icon from the design form menu to print and view the report.
Double-click wWindow1 Class from the Report1 Library window.
The REPORT1.wWindow1 design form displays.
Drag the Push Button from the Component Store to the design form above the Print from BASIC Button.
Type Run Grid Report in the text field in the Property Manager window.
Select MyServer (Default) > Report > REPORT1.rGridReport node from the Enterprise Browser, then drag the REPORT1.rGridReport node to the Run Grid Report button.
The wWindow1_1036 event window displays.
Select the evClick event and the Start New Print Job check boxes, then select Prompt from the Print Destination drop-down list.
Click Update to save changes.
Right-click REPORT1.wWindow1 design form and select Open Window.
The REPORT1.wWindow1 design form runs.
Select Print to Screen icon from the design form menu to print and view report.
Generating Report in mvDesigner
Setting up the Development Environment
Creating a Simple Report
Creating a Batch Report
Modifying Fields at Run Time
Using the Report Graph Control Component
Selecting Print Destination from BASIC