Using the Report Data Grid

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.

To create a new mvD report:
  1. Drag the mvD report from the Component Store to the REPORT1 Library window.

  2. Type rGridReport to name the mvD report Class.

  3. Double-click rGridReport to open the design form, then drag the Entry field from the Component Store to the design form.

  4. 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.

  1. Select External Component from the Component Libraries list.

A new Component Libraries list displays.

  1. Select the Report Lists Library from the Component Libraries list and the Opening 'REPORT1' Pre-Load Status option, then click OK.

  2. Select the External Components icon from the Component Store menu to display all the external components.

  3. Drag the Data Grid from the Component Store to the REPORT1.rGridreport design form.

To configure the Data Grid:
  1. Define 5 columns (column sizes can be adjusted as required) and label the columns:

NOTE

These properties are defined in the General tab, Appearance tab, and Column tab of the Property Manager window.

  1. (Optional) Change the border, grid lines, and cell-heading color.

  2. 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.

NOTE

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).

  1. Close the report.

To create the BASIC program:
  1. Select MyServer (Default) > Subroutines > mvDReport > bp BASIC program from the Enterprise Browser.

  2. Right-click the bp node and select Create New Item...

A new BASIC program item is created.

  1. Type GridReport to name the new item.

  2. Double-click the GridReport node to open the GridReport Editor.

  3. Edit the GridReport BASIC program.

CASE TRIGGERFORM = 'rGridReport' AND TRIGGEREVENT = '$getreportdata'

GOSUB GetReportHeader

GetReportHeader:

HA="Report.Header"

DA="Customer List"

CALL w3mvDInsert(HA,DA,"")

RETURN

The GridReport BASIC program reacts to two events.

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.

To prepare the Data Grid:

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

HA ="iMvdSubList.Col1"

HA<2>="iMvdSubList.Col2"

HA<3>="iMvdSubList.Col3"

HA<4>="iMvdSubList.Col4"

HA<5>="iMvdSubList.Col5"

CALL w3mvDInsert(HA,DA,"")

To compile and catalog the program:
  1. Click compile.

The GridReport BASIC program successfully compiles.

  1. Select Subroutines > mvDReport > bp > GridReport node from the Enterprise Browser.

  2. Right-click the GridReport node and select Catalog Item...

The mvDCatalog Entry window displays.

  1. Select the Allow Anonymous Access check box, then click Save.

To assign the DataName and events to the report:
  1. Double-click rGridReport Class from REPORT1 Library to open the REPORT1.rGridReport design form.

  2. 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.

  1. Click Update to save changes and close window.

  2. Select MyServer (Default) > mvDCatalog > ReportTutorial > GridReport node from the Enterprise Browser.

  3. Drag the GridReport node to the report in the REPORT1.rGrid Report design form.

The rGridReport event window displays.

  1. Select the $getreportdata event check box, select MyServer from the Server drop-down list, then click Update to save the changes.

NOTE

Since the DataNames were assigned earlier using the iMvdSubList instance variable, they do not need to be assigned to the Data Grid component.

  1. Repeat procedure 4.

The Grid mvDCatalog window displays.

  1. Select the $print event check box, then click Update to save changes.

  2. Click the Print to Screen icon from the REPORT1.rGridReport design form to print and view and test the mvD report.

To enhance the mvD report:
  1. 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.

  2. Drag the iMvdDataRef.Header to the Report Heading section of the Report, then define its field properties in the Property Manager window.

  3. Click the Background Components icon, then click the Background Objects icon from the Component Store Menu.

  4. Drag the Label field to the Report Heading section of the design form, then define its field properties in the Property Manager window.

  5. Click the External Components icon from the Component Store menu to display the components, then select the Page Count Object component.

  6. 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.

  7. Select the Page Footer heading to display its field properties in the Property Manager window, then select kTrue from the firstpage drop-down list.

  8. Click the Print to Screen icon from the design form menu to print and view the report.

To run the mvD report from a button:
  1. Double-click wWindow1 Class from the Report1 Library window.

The REPORT1.wWindow1 design form displays.

  1. Drag the Push Button from the Component Store to the design form above the Print from BASIC Button.

  2. Type Run Grid Report in the text field in the Property Manager window.

  3. 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.

  1. Select the evClick event and the Start New Print Job check boxes, then select Prompt from the Print Destination drop-down list.

  2. Click Update to save changes.

  3. Right-click REPORT1.wWindow1 design form and select Open Window.

The REPORT1.wWindow1 design form runs.

  1. Select Print to Screen icon from the design form menu to print and view report.

See Also

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

Summary

Examples