Skip to content

Using Grids

DataFlex grids provide a multi-row, multi-column grid for data display and data entry. Grids are implemented via a hierarchy of objects. An object representing a grid contains a collection of column objects (one for each column in the grid) and a datasource object that provides data for each row and column (grid cell).

The grid classes' underlying technology is Codejock Software's Xtreme Report COM Control. The basic COM classes have been imported using the DataFlex Import Active/x feature. An additional layer of classes has been created to wrap the imported COM classes. This was done to meet the following objectives:

  • To 'specialize' the report control to be used as a row and column-based grid control for data entry and for listing read-only data.
  • To support the DataFlex data dictionary object framework for data modeling and database services.
  • To provide seamless support for the report control's 'virtual mode' for consistently high performance with small or large data sets.
  • To support visual modeling of grids within the Studio.
  • To be feature compatible with DataFlex's legacy grid classes (e.g., support for DataFlex mask strings).

The Grid Classes

Simple Grids

  • cCJGrid – This wraps all of the methods, properties, and events that relate to the grid as a whole. You would use this class for grids that are not connected to a data dictionary object structure.
  • cCJGridColumn – This wraps all of the methods, properties, and events for a single grid column. You would use this class to represent columns inside a cCJGrid object.
  • cCJGridDataSource – This manages the grid's rows and columns of data and wraps all of the methods and properties related to loading, modifying, and saving data. An object of this class is automatically created as a child of each cCJGrid object. The datasource object handle is available via the grid's phoDataSource property.

Data Aware Grids

  • cDbCJGrid – In addition to the cCJGrid interface, this class provides the interface to connect the grid to a data dictionary object structure for displaying, adding, editing, and deleting data from your database.
  • cDbCJGridColumn – In addition to the cCJGridColumn interface, this class binds the grid column to a database table.column and applies all of the appropriate data dictionary column attributes.
  • cDbCJGridDataSource – This is the datasource class that is used to manage the rows and columns of data that are displayed in a data aware grid that is connected to a data dictionary object structure. The datasource object handle is available via the grid's phoDataSource property.

Data Aware Prompt Lists

  • cDbCJGridPromptList – This is a specialized data aware grid class that is used when creating prompt lists. Normally, a prompt list will be part of a modal dialog (dbModalPanel). The cDbCJGridPromptList interface is designed such that when the modal panel is activated, the grid is populated, and when a selection is made, the invoking view is updated.

Legacy Grid Classes

The DataFlex Grid, dbGrid, List, and dbList classes do not belong to the classes that wrap the CodeJock Xtreme Report Control. These classes provide support for legacy grid and prompt list controls from DataFlex revisions prior to revision 16.0.

Object Structures

Each grid needs a datasource object to manage the row and column data. A column object must be created for each column in your grid. The order that the columns are created determines the initial, left-to-right, column order. The datasource object is created automatically, so you will not see it in your code.

Simple Grids

Simple Grids use cCJGrid for the parent grid object and cCJGridColumn for each column object. A single cCJGridDataSource object is created internally by the cCJGrid object, so you do not need to create a datasource object yourself.

Object oCustomerGrid is a cCJGrid
    Set Size to 150 271
    Set Location to 13 11
    Object oCol1 is a cCJGridColumn
        Set piWidth to 37
        Set psCaption to "Number"
    End_Object
    Object oCol0 is a cCJGridColumn
        Set piWidth to 163
        Set psCaption to "Name"
    End_Object
    Object oCol2 is a cCJGridColumn
        Set piWidth to 30
        Set psCaption to "State"
    End_Object
End_Object

Each column's width is controlled by its piWidth property, and the column heading is assigned by setting the psCaption property.

With simple grids, data is loaded into the grid by populating the datasource (not shown in the above example). This is done by populating an array of tDataSourceRow items and sending InitializeData to the grid, passing the tDataSourceRow array. See Loading cCJGrid Data for more information.

Data Aware Grids

Data aware DEO grids are based on the cDbCJGrid, cDbCJGridColumn, and cDbCJGridDataSource classes. These classes are designed to interact with your data-dictionaries and handle all data loading and processing.

Object oCustomer_DD is a Customer_DataDictionary
End_Object
Set Main_DD to oCustomer_DD
Set Server to oCustomer_DD
Object oCustGrid is a cDbCJGrid
    Set Size to 180 281
    Set Location to 5 5
    Object oNum_col is a cDbCJGridColumn
        Set piWidth to 38
        Set psCaption to "Number"
        Entry_Item Customer.Customer_Number
    End_Object
    Object oName_col is a cDbCJGridColumn
        Set piWidth to 183
        Set psCaption to "Customer Name"
        Entry_Item Customer.name
    End_Object
End_Object

The cDbCJGrid object attaches to the view's server data dictionary object. Each grid column binds to a table.column via the Entry_Item command.

See Also