Paged Grids

A grid is a matrix of data fields. Each element of this matrix, called a cell, can hold either text or a bitmap, or both. Grids are organized into rows, columns, and records. In a grid, a row is a grouping of cells that appear on one line in the control. A record is one or more rows that are treated as a logical unit. By default, a record occupies one row in a grid, but a record may also wrap around to the next row when it passes the right edge of the grid. A column identifies a particular cell in a record.

A grid's capacity is limited by available memory. Sometimes, however, you may want to view many records using a grid control. This could pose a problem when you are using normal grids. Just loading all the records into the grid could take an excessive amount of time. To remedy this problem, you may want to use a paged grid.

When you are using the PAGED style in a grid, the grid holds only as many records as can be viewed on the screen. This is called a page of data. The vertical scroll bar found in a normal grid is replaced by four buttons. These buttons respond to requests to get the next record, the previous record, the next page, or the previous page. (Note that you can also apply wheelmouse events to PAGED styled grids.) When the user clicks one of these buttons, the grid sends a message to the program asking for the appropriate data depending on which button was clicked. This data typically comes from an indexed file. The expected program logic is to do one or more READ NEXT or READ PREVIOUS statements to retrieve the data.

Note: By default, if a user switches focus by clicking any of the buttons used to scroll a paged grid, a CMD-GOTO event is not generated. To modify this behavior, set the GRID_BUTTONS_CAUSE_GOTO configuration variable to 1 (on, true, yes).

Paged grids are conceptually similar to paged list boxes. Programmers familiar with paged list boxes, however, may notice some differences in programming paged grids. These differences were designed to make programming the grid's paging logic easier. The noticeable differences are:

Furthermore, paged grids communicate requests for more data through events such as:

Paged grids never hold more data than they can display on the screen. When you are adding a record at the end of a full page, the control deletes the topmost non-heading record. This causes the grid's contents to scroll upward. When you are adding a record to any other position, the last record in the grid is deleted. This causes all records after the one being added to scroll downward.

Note: The current cell is not changed when the grid is paged. In other words, if the grid's cursor is at row 2, column 3, it will be at row 2, column 3 after the user clicks the next record button. This will effectively move the cursor to a new record, even though its physical location has not changed. Unlike other forms of cursor movement, this does not generate any additional events. If you are performing special actions when the cursor enters a new cell (for example, displaying related information outside of the grid), then you should perform the appropriate actions in response to paging events as well as cursor-movement events.
Tip: The paged grid feature is demonstrated in two AcuBench sample project located in the Support > Examples and Utilities area of the Micro Focus Web site. To download these projects, go to: http:// supportline.microfocus.com/examplesandutilities/index.asp. Select Acucorp samples > Graphical User Interfaces > GridTXTViewer.zip and pagedgrid.zip.