Class: cDbCJGridColumn
Properties | Events | Methods | Index of Classes
Models a data-aware grid column within a cDbCJGrid object.
Hierarchy
- cObject
- DfComAutomationObject
- cComAutomationObject
- cCJGridColumnXTP
- cCJGridColumn
- cDbCJGridColumn
Library: Windows Application Class Library
Package: cdbCJGridColumn.pkg
Description
The cDbCJGridColumn class is used to provide columns for data-aware [cDbCJGrid](cDbCJGrid.md) objects. Every column in a grid is represented by a grid column object. Regular [cCJGrid](cCJGrid.md) objects use a [cCJGridColumn](cCJGridColumn.md) object for each column, while data-aware cDbCJGrid objects use a cDbCJGridColumn.
You should review the [cCJGridColumn](cCJGridColumn.md) documentation for a description of the general purpose of a grid column object. This subclass extends those capabilities. The main extensions are:
- The column object is bound to a
table.columnwith theEntry_Itemcommand, which sets thepiBindingTableandpiBindingColumnproperties. This binding is used to: - Move data from the DataDictionary's file buffer to the datasource (
InitialValue). -
Move edited column data back to the DataDictionary object.
-
Based on the table binding information, it uses the DataDictionary to provide a number of services. This includes:
- Setting the column data type and mask.
- Providing the entering, exiting, and validating events.
- Providing prompt links to prompt lists and validation tables.
- Providing status help and tooltip values.
- Setting the column's focusability, skipfound, and autofind states.
- Providing default values for new DataDictionary records.
- Index information concerning the best index ordering for the column (
ColumnOrdering).
In addition, it inherits these features from the [cCJGridColumn](cCJGridColumn.md) class:
- Serves as a proxy object for the Codejock COM ReportControl (it is descended from
cCJReportColumn) and wraps many of the COM properties (psCaption,piWidth,peTextAlignment,Color,TextColor, and many more). - Used to handle grid column change processing (
OnEntering,OnExiting,OnValidating,OnEntry,OnExit,NextColumn,PreviousColumn). - Formats and displays cell data from the datasource (
peDatatype,psMask,OnSetDisplayMetrics,InitialValue). - Handles editing data and updating the datasource with the changes (
OnEndEdit). - Provides support for various types of display and input controls (
pbCheckbox,pbComboButton,pbVDFEditControl). - Provides information about the sort rules for a column (
ColumnSortRules).
A data-aware grid will normally consist of a single cDbCJGrid object, an internally created [cDbCJGridDataSource](cDbCJGridDataSource.md) object, and multiple cDbCJGridColumn objects to define the grid. With data-aware grid columns, the table binding data provides the information to set up the column. This makes the grid column object code simple. The data is loaded and ordered based on the grid's [Server](cDbCJGrid-Property-Server.md) and [Ordering](cDbCJGrid-Property-Ordering.md) properties.
Object oOrderDtl_Grid is a cDbCJGrid
Set Server to OrderDtl_DD
Set Ordering to 1
Set Size to 63 377
Set Location to 90 3
Set peAnchors to anAll
Set pbAllowInsertRow to False
Set pbRestoreLayout to True
Set psLayoutSection to "OrderView_oOrderDtl_Grid1"
Set piLayoutBuild to 6
Set pbHeaderPrompts to True
Object oMark is a cCJGridColumnRowIndicator
End_Object
Object oInvt_Item_ID is a cDbCJGridColumn
Entry_Item Invt.Item_ID
Set piWidth to 91
Set psCaption to "Item ID"
Set psImage to "ActionPrompt.ico"
End_Object
Object oInvt_Description is a cDbCJGridColumn
Entry_Item Invt.Description
Set piWidth to 213
Set psCaption to "Description"
End_Object
Object oInvt_Unit_Price is a cDbCJGridColumn
Entry_Item Invt.Unit_Price
Set piWidth to 53
Set psCaption to "Unit Price"
End_Object
Object oOrderDtl_Qty_Ordered is a cDbCJGridColumn
Entry_Item OrderDtl.Qty_Ordered
Set piWidth to 50
Set psCaption to "Quantity"
End_Object
Object oOrderDtl_Price is a cDbCJGridColumn
Entry_Item OrderDtl.Price
Set piWidth to 62
Set psCaption to "Price"
End_Object
Object oOrderDtl_Extended_Price is a cDbCJGridColumn
Entry_Item OrderDtl.Extended_Price
Set piWidth to 81
Set psCaption to "Total"
End_Object
End_Object
In the above example, the cCJGridColumnRowIndicator is a non-data-aware subclass of the cCJGridColumn class. You will usually not mix regular and data-aware grid classes in a cDbCJGrid class, but it is allowed. However, you may not place a cDbCJGridColumn class inside of a non-data-aware cCJGrid class.
CalculatedColumns
Data-aware grid columns augment the [InitialValue](cCJGridColumn-Function-InitialValue.md) function to load data from your table buffers into your datasource. InitialValue uses table binding properties, [piBindingTable](cCJGridColumn-Property-piBindingTable.md) and [piBindingColumn](cCJGridColumn-Property-piBindingColumn.md) (which are set with the Entry_Item command) to move the table data into the datasource.
If you do not set any binding table information (i.e., no Entry_Item command), this column is considered to be a calculated column. In this case, when InitialValue is called, it calls the [OnSetCalculatedValue](cDbCJGridColumn-Event-OnSetCalculatedValue.md) event. You can use this event to create a calculated value for the cell.
Object oOrderDtl_Tax is a cDbCJGridColumn
Set piWidth to 81
Set psCaption to "Tax"
Set pbFocusable to False
Procedure OnSetCalculatedValue String ByRef sValue
Number nTaxRate
Get TaxRate to nTaxRate
Move (OrderDtl.Extended_Price * nTaxRate) to sValue
End_Procedure
End_Object
Because the calculation is handled in code, you can make the calculation as complex as needed, including the use of conditional code.
Procedure OnSetCalculatedValue String ByRef sValue
String sTaxable
Number nTaxRate
Get TaxRate to nTaxRate
Get SelectedRowValue of oOrderDtl_Taxable to sTaxable
If (sTaxable = "Y") Begin
Move (OrderDtl.Extended_Price * nTaxRate) to sValue
End
Else Begin
Move 0 to sValue
End
End_Procedure