Skip to content

CreateDataSourceRow - cCJGridDataSource

Creates a data source row using whatever rules the datasource uses for creating rows

Type: Function
Return Data Type: tDataSourceRow

Syntax

Function CreateDataSourceRow Returns tDataSourceRow

Call Example

Get CreateDataSourceRow to tDataSourceRowVariable

Description

CreateDataSourceRow is used to create a new row using whatever rules the datasource and grid column objects have for creating rows. It returns the row in a tDataSourceRow variable. You can then add this to your datasource array.

The row is created by sending InitialValue to each grid column object, which returns a value that is added to the tDataSourceRow's column value array.

cCJGrid / cCJGridDataSource

This is usually only called when the user adds a new row. You can augment InitialValue in the grid column object to return an appropriate initialization value for each column.

cDbCJGrid / cDbCJGridDataSource

This is called whenever a new DataDictionary record is added to the datasource's cache. In this case, the cDbCJGridColumn's InitialValue will return the database value represented by piBindingTable and piBindingColumn. If there is no binding value, a calculated value is determined by sending OnSetCalculatedValue.

For the most part, this all occurs automatically and, because data can be cached in and cached out, it occurs all the time. However, if your data-aware grid is static, you can use this message to manually load your data. The following code would load custom data in a cDbCJGrid object:

Procedure LoadData 
    Handle hoServer hoDataSource
    Boolean bFound
    tDataSourceRow[] DataSource
    Integer iRows iFile

    Get Server to hoServer
    Get Main_File of hoServer to iFile
    Send Request_Read of hoServer FIRST_RECORD iFile 1
    Move (Found) to bFound
    Get phoDataSource to hoDataSource
    While bFound
        If (Customer.State<>"CA") Begin
            // creates a datasourcerow based on current buffer data
            Get CreateDataSourceRow of hoDataSource to DataSource[iRows]
            Increment iRows
        End
        Send Request_Read of hoServer GT iFile 1
        Move (Found) to bFound
    Loop
    Send InitializeData DataSource
    Send MovetoFirstRow
End_Procedure

Procedure Activating
    Send LoadData
End_Procedure

Return Value

A tDataSourceRow variable representing a row.