Skip to content

pbStaticData - cDbCJGrid

Determines if your grid data is static or dynamic

Type: Property
Access: Read/Write
Data Type: Boolean
Parameters: None

Syntax

Property Boolean pbStaticData
Access Type Syntax
Read Access: Get pbStaticData to BooleanVariable
Write Access: Set pbStaticData to BooleanVariable/Value

Description

A cDbCJGrid can be dynamic or static as determined by pbStaticData. By default, pbStaticData is False and your grids are dynamic.

Dynamic Grids

Normally a cDbCJGrid works with a dynamic data source. It does not attempt to load all of your records and it refreshes the data source any time you jump to a new location in your grid (e.g., a find or begin/end of grid request). In this mode you data is cached and data is only loaded into the grid as needed. When the cache gets too large, some rows are cached out. This dynamic mode makes it possible to work with extremely large grids and prompt lists.

When a grid is dynamic the data source object (cDbCJGridDataSource) must manage the finding of all records. The data source must know how to find the first, last or a specified record. It must also know how to find the records around the specified record in the proper index order. This is all done automatically by the cDbCJGridDataSource class. As a user navigates through the grid records are read into and out of the data source cache as needed. The developer can manually find any record and refresh the grid by sending RefreshDataFromMatchingRow. They can refresh the data based around the SelectedRow by sending RefreshDataFromSelectedRow. They can initialize the data at the start or end of the data by sending MoveToRow and MoveToLastRow.

Static Grids

By setting the pbStaticData property to True, you are telling the grid and its data source that the data is static. All data should be loaded just one time and once loaded it should never be automatically refreshed. This mode is useful when you need to deal with all of your data at one time and number of rows is small enough that it is reasonable to load them all up front.

By simply setting pbStaticData to True, your grid or prompt list will become static. When activating the grid, the data will be loaded in the same automatic fashion as the dynamic grid, but it will all be loaded up front and just once. For example, by setting a cDbCJGridPromptList's pbStaticData to True, it will be become static. If pbHeaderReorders is true, when you click on column headers to reorder the list, the data source will be sorted and not refreshed. This allows you to sort and search by all columns and not just the indexed columns. Of course, if the number of rows is too large it may take an unacceptable amount of time to load and sort the data.

With static grids, you can bypass the automatic loading of row data and use InitializeData to provide a customized set of data.

Set pbStaticData To True
:
// create our own custom set of data
Procedure LoadData 
    Handle hoDataSource 
    Boolean bFound
    Integer iRows
    tDataSourceRow[] TheData

    Get phoDataSource to hoDataSource

    Clear Customer
    Find ge Customer by Index.1
    Move (Found) to bFound
    While bFound
        If (Customer.Status="Y") Begin
            // creates a data sourcerow based on current buffer data
            Get CreateDataSourceRow of hoDataSource to TheData[iRows]
            Increment iRows
        End
        Find gt Customer by Index.1
        Move (Found) to bFound
    Loop
    Send InitializeData TheData
    Send MovetoFirstRow
End_Procedure

Refreshing a Static Grid

If you need to refresh and reload a static grid, perhaps ebcause the underlying data has changed, you may do so one of two ways, depending on how your static grid is loaded. If your data is being custom loaded (as above), just call the method that loads your grid again. For example, in the above example, you could call the above LoadData method again to refresh your data.

If your static data was being loaded automatically when the grid was activated, you may force it to load again by resetting your data source followed by MoveToFirstRow or MoveToLastRow.

Send Reset of (phoDataSource(Self))
Send MovetoFirstRow

You would want to do this if you had a constrained static list that is being dynamically changed.